Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When my app is in background, push notifications are handled only if I touch the top notification banner

I've implemented

application:didReceiveRemoteNotification:

to store data in my app when a push notification is received.

However when my app is in background and I receive a notification, the data is stored only if I touch the notification banner appearing on top:

enter image description here

Instead, if I touch the app icon to reopen it, the content of the notification is not stored:

enter image description here

Since I'm receiving the notifications only when I use the distribution profile, I'm not sure if application:didReceiveRemoteNotification: is invoked only when I push the notification banner on top.

I thought it is always invoked at the time a notification is received, and not after a user action on the device.

UPDATE. I don't know if this can help but, just to let you know, I haven't implemented any of these methods:

– applicationDidEnterBackground:
– applicationWillEnterForeground:
- applicationDidBecomeActive:
like image 813
aneuryzm Avatar asked Jul 22 '12 18:07

aneuryzm


1 Answers

I think I've found out why. From documentation:

If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications).

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

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

However, I'm wondering if there is a way to load the payload even if the app has been re-opened by touching the icon.

like image 147
aneuryzm Avatar answered Sep 30 '22 06:09

aneuryzm