Skip to content

Commit e25c017

Browse files
authored
Fix/remote params exception on app id update (#913)
* WIP - Fix for the remoteParams null exception on app id update * Customer seeing issue with remoteParams being null in stacktrace exception after changing organization and app id of mobile app Added 2 null (1 for app id and 1 for remoteParams) checks where null remoteParams exception occurs * Need to validate if this is an issue with remoteParams being null for changed app ids * Another issue would be if this is simply missing a null check on one of the routes to the null exception * Attempting to reproduce this first before making an crazy changes * Reproduced this issue with the following scenario: 1. Fresh install of app using OneSignal SDK with a valid app id and subscribed for push 2. New player is created in OneSignal app dashboard 3. Create an entirely new app on OneSignal dashboard 4. Delete the old app 5. Install updated app using OneSignal SDK with a new valid app id and subscribed for push 6. Crash occurs in OneSignal SDK because of a few possible scenarios (invalid app id or player id) * Basically we need to decide the correct way to handle this issue. The SDK should not have any other crashes now with the null checks in place, but should we add a backend patch also for old SDK users so it takes place now * Fixed null check to account for a previous null emailId also * This now follows the exact logic of OSSubscriptionState.setUserId
1 parent f326470 commit e25c017

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSEmailSubscriptionState.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ void clearEmailAndId() {
6262
}
6363

6464
void setEmailUserId(@NonNull String id) {
65-
boolean changed = !id.equals(emailUserId);
65+
boolean changed = false;
66+
if (id == null)
67+
changed = emailUserId != null;
68+
else if (!id.equals(emailUserId))
69+
changed = true;
70+
6671
emailUserId = id;
6772
if (changed)
6873
observable.notifyChange(this);

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalChromeTabAndroidFrame.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ static void setup(String appId, String userId, String adId) {
99
if (opened)
1010
return;
1111

12-
if (OneSignal.remoteParams.enterprise)
12+
if (OneSignal.remoteParams == null || OneSignal.remoteParams.enterprise)
1313
return;
1414

15-
if (userId == null)
15+
if (appId == null || userId == null)
1616
return;
1717

1818
String params = "?app_id=" + appId + "&user_id=" + userId;

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRemoteParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static private void processJson(String json, final @NonNull CallBack callBack) {
111111
receiveReceiptEnabled = responseJson.optBoolean("receive_receipts_enable", false);
112112
outcomesParams = new OutcomesParams();
113113

114-
//Process outcomes params
114+
// Process outcomes params
115115
if (responseJson.has(OUTCOME_PARAM)) {
116116
JSONObject outcomes = responseJson.optJSONObject(OUTCOME_PARAM);
117117

0 commit comments

Comments
 (0)