0

Remote Notifications are meant to be executed only if user clicks on one of them by default.

But when user clicks on the app icon, even with presence of the red "badge" incremented, notifications aren't taken into account, as evoked by the documentation:

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification.

Using Cordova/PhoneGap in the Javascript side (not with objective-C directly), is there a callback that I could set to trigger some codes (like a refresh of data) when the user clicks on the app's icon? I read the documentation but can't find a similar thing.

Otherwise I would present stale data to user ...

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mik378
  • 21,881
  • 15
  • 82
  • 180

1 Answers1

1

If You take a look the Launch option keys You will find a UIApplicationLaunchOptionsRemoteNotificationKey:

UIApplicationLaunchOptionsRemoteNotificationKey The presence of this key indicates that a remote notification is available for the app to process. The value of this key is an NSDictionary containing the payload of the remote notification. See the description of application:didReceiveRemoteNotification: for further information about handling remote notifications. This key is also used to access the same value in the userInfo dictionary of the notification named UIApplicationDidFinishLaunchingNotification.

Mat
  • 7,613
  • 4
  • 40
  • 56
  • That is Objective-C ;) – Mik378 Jul 04 '14 at 15:22
  • Yes i know, as i said in a comment in your another question, the plug-in should be handle this. Could you modify the plug-in? – Mat Jul 04 '14 at 15:24
  • Yes, I have its code so I could, but I wonder if they were a more direct way from Javascript, letting the plugin untouched. – Mik378 Jul 04 '14 at 15:25
  • Ok, I don't know that, but I think that even if you're using js, you should try to access on that value. – Mat Jul 04 '14 at 15:29
  • For example, I found this type of event: http://cordova.apache.org/docs/en/3.5.0/cordova_events_events.md.html#resume I just have to find a way to not trigger it when the user was clicking on a notification and triggers it when app icon is clicked. Drawback: a refresh of data would be made EVERYTIME the app gets in foreground – Mik378 Jul 04 '14 at 15:32
  • The trick is that I've never read Objective-C before. Reading some basic course about it :) since I agree that the best way would be to patch the plugin to be aware of remote notifications when app icon is typed. – Mik378 Jul 04 '14 at 15:36
  • Take a look at [this](http://stackoverflow.com/a/5425987/251513), maybe you can just try or directly contact the dev of that plug-in :) – Mat Jul 04 '14 at 15:43
  • Thanks for the link :) I will try to do it myself, but firstly I will read some lessons about type of Events (like :didReceiveRemoteNotification is) – Mik378 Jul 04 '14 at 15:50
  • Good luck :) keep in mind that didReceiveRemoteNotification will fires up just if the app is running. – Mat Jul 04 '14 at 15:57