From 504eace0cad325419fd0976b71d658ee2531a6f6 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 12 Jan 2023 12:49:33 -0800 Subject: [PATCH 1/2] need to fetch user after successfully identifying user * The anonymous user has been identified, but we still need to Fetch User as we cleared local data * This will hydrate the onesignal_id again as well as other user properties --- .../OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift index 66514481f..32e3dc164 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift @@ -216,8 +216,9 @@ class OSUserExecutor { static func executeIdentifyUserRequest(_ request: OSRequestIdentifyUser) { OneSignalClient.shared().execute(request) { _ in - // the anonymous user has been identified, no further action needed, no need to fetch user - executePendingRequests() + // the anonymous user has been identified, still need to Fetch User as we cleared local data + fetchUser(aliasLabel: OS_EXTERNAL_ID, aliasId: request.aliasId, identityModel: request.identityModelToUpdate) + executePendingRequests() // TODO: Here or before fetch? } onFailure: { error in // Returns 409 if any provided (label, id) pair exists on another User, so the SDK will switch to this user. if error?._code == 409 { From 436294bb48857ee685fd3df32a8a90434a63fc34 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 12 Jan 2023 13:04:27 -0800 Subject: [PATCH 2/2] fix bug in firing push subscription observer * calculateIsOptedIn and calculateIsEnabled were not actually using the passed in arguments --- .../OneSignalUser/Source/OSSubscriptionModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift index 0fab2106f..8551ba7a3 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift @@ -293,13 +293,13 @@ extension OSSubscriptionModel { // Calculates if the device is opted in to push notification. // Must have permission and not be opted out. func calculateIsOptedIn(accepted: Bool, isDisabled: Bool) -> Bool { - return _accepted && !_isDisabled + return accepted && !isDisabled } // Calculates if push notifications are enabled on the device. // Does not consider the existence of the subscription_id, as we send this in the request to create a push subscription. func calculateIsEnabled(address: String?, accepted: Bool, isDisabled: Bool) -> Bool { - return (self.address != nil) && _accepted && !_isDisabled + return address != nil && accepted && !isDisabled } func updateNotificationTypes() {