Skip to content

Commit e701f9f

Browse files
committed
Fix NPE under UserState
* currentUserState might be null when application goes to background * Replace currentUserState with getCurrentUserState() to avoid NPE
1 parent 5ad3a89 commit e701f9f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ void clearLocation() {
221221
boolean persist() {
222222
if (toSyncUserState != null) {
223223
synchronized (LOCK) {
224-
boolean unSynced = currentUserState.generateJsonDiff(toSyncUserState, isSessionCall()) != null;
224+
// In case current state is being clean in background, save toSyncUserState for next player sync
225+
boolean unSynced = getCurrentUserState().generateJsonDiff(toSyncUserState, isSessionCall()) != null;
225226
toSyncUserState.persistState();
226227
return unSynced;
227228
}

0 commit comments

Comments
 (0)