parse-push-plugin icon indicating copy to clipboard operation
parse-push-plugin copied to clipboard

Hide/show iOS banner push in open app

Open youstartlabs opened this issue 8 years ago • 2 comments

Hi, Thanks for the great plugin. I am using the latest release of the plugin V1.0.7 . I am developing on iOS 10.2 . My issue is related to banner push in iOS. When my app is open, I receive notifications properly, but each time a notification drops from above, similar to what happens when the app is closed. This becomes a trouble when I am sending and receiving push for a chat. Every message drops a notification from top and it takes time for it to disappear. I am wondering if there is any setting available in the plugin to control hiding/showing of the banner notification when the app is open. If not in plugin, is there any iOS native setting I can change in a file or Xcode which allows control over the banner push. This SO issue relates to similar, but opposite problem, where they want to show the banner push.

youstartlabs avatar Apr 22 '17 16:04 youstartlabs

Did you find a solution in the end? I am facing a similar problem, I do not want the notification banner when the app is opened.

magickaito avatar Jul 17 '17 05:07 magickaito

In case anyone facing same problem, I manage to hide the notification by editing userNotificationCenter:willPresentNotification method in ParsePushPlugin.m:

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:
(UNNotification *)notification withCompletionHandler:(void (^)
(UNNotificationPresentationOptions))completionHandler {
NSLog(@"User info %@", notification.request.content.userInfo);

UIApplication *application = [UIApplication sharedApplication];
[self jsCallback:notification.request.content.userInfo withAction:(application.applicationState == UIApplicationStateActive) ? @"RECEIVE" : @"OPEN"];

//added this line to hide the notification
completionHandler(UNNotificationPresentationOptionNone);

//commented out this line to hide the notification
//completionHandler(UNNotificationPresentationOptionAlert);
}

magickaito avatar Jul 19 '17 03:07 magickaito