File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
iOS_SDK/OneSignalSDK/OneSignalUser/Source Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ class OSUserExecutor {
8080 let subscriptionObject = parseSubscriptionObjectResponse ( response) {
8181 for subModel in subscriptionObject {
8282 if subModel [ " type " ] as? String == " iOSPush " ,
83- subModel [ " token " ] as? String == originalPushToken {
83+ areTokensEqual ( tokenA : originalPushToken , tokenB : subModel [ " token " ] as? String ) { // response may have "" token or no token
8484 OneSignalUserManagerImpl . sharedInstance. user. pushSubscriptionModel. hydrate ( subModel)
8585 if let subId = subModel [ " id " ] as? String {
8686 OSNotificationsManager . setPushSubscriptionId ( subId)
@@ -130,6 +130,21 @@ class OSUserExecutor {
130130 }
131131 }
132132
133+ /**
134+ Returns if 2 tokens are equal. This is needed as a nil token is equal to the empty string "".
135+ */
136+ static func areTokensEqual( tokenA: String ? , tokenB: String ? ) -> Bool {
137+ // They are both strings or both nil
138+ if tokenA == tokenB {
139+ return true
140+ }
141+ // One is nil and the other is ""
142+ if ( tokenA == nil && tokenB == " " ) || ( tokenA == " " && tokenB == nil ) {
143+ return true
144+ }
145+ return false
146+ }
147+
133148 static func parseSubscriptionObjectResponse( _ response: [ AnyHashable : Any ] ? ) -> [ [ String : Any ] ] ? {
134149 return response ? [ " subscriptions " ] as? [ [ String : Any ] ]
135150 }
You can’t perform that action at this time.
0 commit comments