0

I'm not (yet :)) an expert in iOS development.

I use Cordova/PhoneGap to convert my Javascript app into native app.
I use PushPlugin in order to handle notifications.

The whole works well when user clicks on the notification alert: handled by the application through the onNotificationAPN callback.

However, when user clicks on the app icon directly (with the badge incremented), the notification is not handled => onNotificationAPN callback not fired.

I'm not expert in Objective-C and iOS environment but I'm suspecting this snippet code from PushPlugin to not achieve my requirement:

- (void)applicationDidBecomeActive:(UIApplication *)application {

    NSLog(@"active");

    //zero badge
    application.applicationIconBadgeNumber = 0;

    if (self.launchNotification) {
        PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];

        pushHandler.notificationMessage = self.launchNotification;
        self.launchNotification = nil;
        [pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];
    }
}

How to handle notification when user clicks on the app's icon rather than the alert ?
Especially, why isn't it a default in this plugin? Does it make sense I ignore?
Indeed, it would lead to many unprocessed notifications as users usually clicks on the app icon rather than the alert.

Mik378
  • 21,881
  • 15
  • 82
  • 180
  • I don't know phonegap or pushplugin but in iOS native application If your app in back ground you can handle the push notification only by tapping the alert. – jailani Jul 04 '14 at 10:26
  • @jailani But what is the real reason regarding this behavior? Why not handling the notification? When I'm using Whatsapp for instance, and clicking on the app's icon, I expect the app to show me new conversations alerts, what it does. I don't want to "pull" for new data each time the user's clicks on the app even if there were no current notifications. – Mik378 Jul 04 '14 at 10:27
  • I am sorry another one callback will get called if the application receives notification even if the app is not in the background – jailani Jul 04 '14 at 10:39
  • @jailani Does it mean that in traditional iOS native apps, when user's clicks on the app icon, there is ALWAYS a process that PULLS for new data ? Of course, this questions concerns the case when the app is not fully closed, but in background initially. – Mik378 Jul 04 '14 at 10:41
  • before I click the app icon that delegate method will called on that method we can receive the information pushed by APNS and we can update the data source inside the application. – jailani Jul 04 '14 at 10:45
  • I understand, so it means that to achieve my use case, I have to "patch" the plugin code to retrieve notifications. – Mik378 Jul 04 '14 at 10:47
  • @Mik378 This UIApplicationDelegate callback that you've showed, will be called each time the user opens the app. So i don't know phonegap, but i think that in your case if there is a notification in "pending" and You open the app from the icon, the if statement should be true. – Mat Jul 04 '14 at 13:04

0 Answers0