Skip to content

Commit aff3fd0

Browse files
authored
Crash reported by several people pointing null from getTags success (#934)
* Added null and empty check for `getTags` response and assign to empty json string if necessary
1 parent d6e0700 commit aff3fd0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
package com.onesignal;
2929

30-
import android.support.annotation.NonNull;
3130
import android.support.annotation.Nullable;
3231

3332
import org.json.JSONException;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ GetTagsResult getTags(boolean fromServer) {
2727
@Override
2828
void onSuccess(String responseStr) {
2929
serverSuccess = true;
30+
31+
// This should not typically come from the server as null or empty, but due to Issue #904
32+
// This check is added and will prevent further crashes
33+
// https://github.com/OneSignal/OneSignal-Android-SDK/issues/904
34+
if (responseStr == null || responseStr.isEmpty())
35+
responseStr = "{}";
36+
3037
try {
3138
JSONObject lastGetTagsResponse = new JSONObject(responseStr);
3239
if (lastGetTagsResponse.has("tags")) {

0 commit comments

Comments
 (0)