File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ - (void)registerUserWithState:(OSUserState *)registrationState withSuccess:(OSMu
148148 // update push player id
149149 if (results.count > 0 && results[OS_PUSH][@" id" ]) {
150150 self.currentSubscriptionState .userId = results[OS_PUSH][@" id" ];
151+
152+ // Player record was deleted so we should reset external user id
153+ let cachedPlayerId = [OneSignalUserDefaults.initStandard getSavedStringForKey: OSUD_PLAYER_ID_TO defaultValue: nil ];
154+ if (cachedPlayerId && ![results[OS_PUSH][@" id" ] isEqualToString: cachedPlayerId]) {
155+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" Player id has changed. Clearing cached external user id" ]];
156+ [OneSignalUserDefaults.initStandard saveStringForKey: OSUD_EXTERNAL_USER_ID withValue: nil ];
157+ }
151158
152159 // Save player_id to both standard and shared NSUserDefaults
153160 [OneSignalUserDefaults.initStandard saveStringForKey: OSUD_PLAYER_ID_TO withValue: self .currentSubscriptionState.userId];
You can’t perform that action at this time.
0 commit comments