Skip to content

Commit

Permalink
the completionHandler moved in the else statement (phonegap#2417)
Browse files Browse the repository at this point in the history
  • Loading branch information
knight9999 authored and macdonst committed Jun 21, 2018
1 parent a70a118 commit 6d38ec3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (AppDelegate *)pushPluginSwizzledInit
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;

[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(pushPluginOnApplicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
Expand All @@ -83,7 +83,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N

// app is in the background or inactive, so only call notification callback if this is a silent push
if (application.applicationState != UIApplicationStateActive) {

NSLog(@"app in-active");

// do some convoluted logic to find out if this should be a silent push.
Expand Down Expand Up @@ -126,9 +126,9 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
NSLog(@"just put it in the shade");
//save it for later
self.launchNotification = userInfo;
completionHandler(UIBackgroundFetchResultNewData);
}

completionHandler(UIBackgroundFetchResultNewData);

} else {
completionHandler(UIBackgroundFetchResultNoData);
}
Expand All @@ -137,7 +137,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
- (void)checkUserHasRemoteNotificationsEnabledWithCompletionHandler:(nonnull void (^)(BOOL))completionHandler
{
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {

switch (settings.authorizationStatus)
{
case UNAuthorizationStatusDenied:
Expand Down Expand Up @@ -174,7 +174,7 @@ - (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification {
self.coldstart = [NSNumber numberWithBool:NO];
[pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];
}

[[NSNotificationCenter defaultCenter] postNotificationName:pushPluginApplicationDidBecomeActiveNotification object:nil];
}

Expand All @@ -188,7 +188,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
pushHandler.notificationMessage = notification.request.content.userInfo;
pushHandler.isInline = YES;
[pushHandler notificationReceived];

completionHandler(UNNotificationPresentationOptionNone);
}

Expand All @@ -201,7 +201,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
NSMutableDictionary *userInfo = [response.notification.request.content.userInfo mutableCopy];
[userInfo setObject:response.actionIdentifier forKey:@"actionCallback"];
NSLog(@"Push Plugin userInfo %@", userInfo);

switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateActive:
{
Expand All @@ -226,13 +226,13 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
completionHandler();
});
};

PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];

if (pushHandler.handlerObj == nil) {
pushHandler.handlerObj = [NSMutableDictionary dictionaryWithCapacity:2];
}

id notId = [userInfo objectForKey:@"notId"];
if (notId != nil) {
NSLog(@"Push Plugin notId %@", notId);
Expand All @@ -241,10 +241,10 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
NSLog(@"Push Plugin notId handler");
[pushHandler.handlerObj setObject:safeHandler forKey:@"handler"];
}

pushHandler.notificationMessage = userInfo;
pushHandler.isInline = NO;

[pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];
}
}
Expand Down

0 comments on commit 6d38ec3

Please sign in to comment.