Skip to content

feat: Codepushserverurl was added #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string moduleConfig="true" name="CodePushDeploymentKey">deployment-key-here</string>
<string moduleConfig="true" name="CodePushServerUrl">server-url-here</string>
<string name="app_name">CodePushDemoApp</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static String getServiceUrl() {
return mServerUrl;
}


public CodePush(String deploymentKey, Context context, boolean isDebugMode) {
mContext = context.getApplicationContext();

Expand All @@ -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();
Expand Down Expand Up @@ -129,18 +136,19 @@ 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);

if (!property.isEmpty()) {
return property;
} else {
CodePushUtils.log("Specified " + propertyName + " is empty");
}
}
}

return null;
Expand Down Expand Up @@ -284,8 +292,8 @@ public String getJSBundleFileInternal(String assetsBundleFileName) {
}
}

public String getServerUrl() {
return mServerUrl;
private String getServerUrl() {
return this.mServerUrl;
}

void initializeUpdateAfterRestart() {
Expand Down