File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 2 files changed +8
-3
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];
Original file line number Diff line number Diff line change @@ -2562,9 +2562,7 @@ + (BOOL)shouldUpdateExternalUserId:(NSString*)externalId withRequests:(NSDiction
25622562 bool updateExternalUserId = ![self .existingPushExternalUserId isEqualToString: externalId]
25632563 && !requests[@" email" ];
25642564
2565- // If we are making a request to email user, we need validate both external user ids
2566- bool updateEmailExternalUserId = (![self .existingPushExternalUserId isEqualToString: externalId]
2567- && requests[@" email" ]
2565+ bool updateEmailExternalUserId = (requests[@" email" ]
25682566 && ![self .existingEmailExternalUserId isEqualToString: externalId]);
25692567
25702568 return updateExternalUserId || updateEmailExternalUserId;
You can’t perform that action at this time.
0 commit comments