Skip to content

Commit

Permalink
Merge pull request #189 from blueshift-labs/fix/autoRegisterForPushOn…
Browse files Browse the repository at this point in the history
…AuthotizationStatusChange

Fix/auto register for push on authotization status change
  • Loading branch information
ketanshikharebsft authored Feb 12, 2021
2 parents c7ac11d + d4b7061 commit 5e04273
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions BlueShift-iOS-SDK/BlueShiftAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ - (void)registerForSilentPushNotification {
if (@available(iOS 10.0, *)) {
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
if ([settings authorizationStatus] != UNAuthorizationStatusAuthorized) {
if (![[BlueShift sharedInstance] getDeviceToken]) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
[self checkUNAuthorizationStatus];
[BlueshiftLog logInfo:@"config.enablePushNotification is set to false. Registered for background silent notifications" withDetails:nil methodName:nil];
} else {
Expand Down Expand Up @@ -169,6 +167,9 @@ - (BOOL)validateChangeInUNAuthorizationStatus {
if(!lastModifiedUNAuthorizationStatus || [lastModifiedUNAuthorizationStatus isEqualToString:kNO]) {
[self setLastModifiedUNAuthorizationStatus: kYES];
[BlueshiftLog logInfo:@"UNAuthorizationStatus status changed to YES" withDetails:nil methodName:nil];
if ([BlueShift sharedInstance].config.enablePushNotification || [BlueShift sharedInstance].config.enableSilentPushNotification) {
[[[BlueShift sharedInstance]appDelegate] registerForNotification];
}
return YES;
}
} else {
Expand Down

0 comments on commit 5e04273

Please sign in to comment.