Skip to content

Commit

Permalink
fix: foreground notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
stnmtz authored Jul 27, 2021
1 parent 448336b commit e14fe25
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,32 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
}

} else {
completionHandler(UIBackgroundFetchResultNoData);
NSLog(@"as a silent push, but with inline true");
void (^safeHandler)(UIBackgroundFetchResult) = ^(UIBackgroundFetchResult result){
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(result);
});
};

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);
[pushHandler.handlerObj setObject:safeHandler forKey:notId];
} else {
NSLog(@"Push Plugin notId handler");
[pushHandler.handlerObj setObject:safeHandler forKey:@"handler"];
}

pushHandler.notificationMessage = userInfo;
pushHandler.isInline = YES;
[pushHandler notificationReceived];
// completionHandler(UIBackgroundFetchResultNoData);
}
}

Expand Down

0 comments on commit e14fe25

Please sign in to comment.