From d01e9d9e75072228d715c92b3bc03bd52723366b Mon Sep 17 00:00:00 2001 From: yasindalkilic Date: Fri, 25 Apr 2025 09:48:20 +0300 Subject: [PATCH] feat: Codepushserverurl was added --- .../app/src/main/res/values/strings.xml | 1 + .../microsoft/codepush/react/CodePush.java | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Examples/CodePushDemoApp/android/app/src/main/res/values/strings.xml b/Examples/CodePushDemoApp/android/app/src/main/res/values/strings.xml index 638fc3009..e70edc574 100644 --- a/Examples/CodePushDemoApp/android/app/src/main/res/values/strings.xml +++ b/Examples/CodePushDemoApp/android/app/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ deployment-key-here + server-url-here CodePushDemoApp diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 2718204d6..2fa29f879 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -58,6 +58,7 @@ public static String getServiceUrl() { return mServerUrl; } + public CodePush(String deploymentKey, Context context, boolean isDebugMode) { mContext = context.getApplicationContext(); @@ -81,8 +82,14 @@ public CodePush(String deploymentKey, Context context, boolean isDebugMode) { String publicKeyFromStrings = getCustomPropertyFromStringsIfExist("PublicKey"); if (publicKeyFromStrings != null) mPublicKey = publicKeyFromStrings; + // Make this more explicit with logging String serverUrlFromStrings = getCustomPropertyFromStringsIfExist("ServerUrl"); - if (serverUrlFromStrings != null) mServerUrl = serverUrlFromStrings; + if (serverUrlFromStrings != null) { + CodePushUtils.log("Setting server URL from strings.xml: " + serverUrlFromStrings); + mServerUrl = serverUrlFromStrings; + } else { + CodePushUtils.log("Using default server URL: " + mServerUrl); + } clearDebugCacheIfNeeded(null); initializeUpdateAfterRestart(); @@ -129,10 +136,11 @@ private String getPublicKeyByResourceDescriptor(int publicKeyResourceDescriptor) private String getCustomPropertyFromStringsIfExist(String propertyName) { String property; - + String packageName = mContext.getPackageName(); + // This is the key change - we're looking for the exact property name with "CodePush" prefix int resId = mContext.getResources().getIdentifier("CodePush" + propertyName, "string", packageName); - + if (resId != 0) { property = mContext.getString(resId); @@ -140,7 +148,7 @@ private String getCustomPropertyFromStringsIfExist(String propertyName) { return property; } else { CodePushUtils.log("Specified " + propertyName + " is empty"); - } + } } return null; @@ -284,8 +292,8 @@ public String getJSBundleFileInternal(String assetsBundleFileName) { } } - public String getServerUrl() { - return mServerUrl; + private String getServerUrl() { + return this.mServerUrl; } void initializeUpdateAfterRestart() {