Skip to content

Commit 07c0a9e

Browse files
committed
update to pull IAMs when the push sub ID changes
* Motivation: The Messaging Controller was pulling IAMs when the push sub observer fires with any change. As a result, it was pulling IAMs more often than needed. * Instead, only pull IAMs when the subscription_ID has changed and is valid.
1 parent f8063e2 commit 07c0a9e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

iOS_SDK/OneSignalSDK/Source/OSMessagingController.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,16 +968,21 @@ - (void)onApplicationDidBecomeActive {
968968

969969
#pragma mark OSPushSubscriptionObserver Methods
970970
- (void)onOSPushSubscriptionChangedWithStateChanges:(OSPushSubscriptionStateChanges * _Nonnull)stateChanges {
971+
// Don't pull IAMs if the new subscription ID is nil
971972
if (stateChanges.to.id == nil) {
972-
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"onOSPushSubscriptionChangedWithStateChanges: changed to nil subscription id"];
973+
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"OSMessagingController onOSPushSubscriptionChangedWithStateChanges: changed to nil subscription id"];
973974
return;
974975
}
975-
// Pull new IAMs when the subscription id changes to a new valid subscription id
976+
// Don't pull IAMs if the subscription ID has not changed
976977
if (stateChanges.from.id != nil &&
977978
[stateChanges.to.id isEqualToString:stateChanges.from.id]) {
978-
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"onOSPushSubscriptionChangedWithStateChanges: changed to new valid subscription id"];
979-
[self getInAppMessagesFromServer:stateChanges.to.id];
979+
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"OSMessagingController onOSPushSubscriptionChangedWithStateChanges: changed to the same subscription id"];
980+
return;
980981
}
982+
983+
// Pull new IAMs when the subscription id changes to a new valid subscription id
984+
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"OSMessagingController onOSPushSubscriptionChangedWithStateChanges: changed to new valid subscription id"];
985+
[self getInAppMessagesFromServer:stateChanges.to.id];
981986
}
982987

983988
@end

0 commit comments

Comments
 (0)