1

I have a problem. When user receives a remote or local notification but he don't read , the notification lost from "userInfo" if the user open the app tapping over the app icon (not on the notification in the Notification Center)

Is there any way to recover the last notification "userInfo" anytime?

Thanks!

mhergon
  • 1,688
  • 1
  • 18
  • 39

1 Answers1

2

I don't believe there is. It would be up to the application to keep track of the info in any notifications that it schedules. Then when the application is loaded, you would have to look through the list of these saved notifications to find the most recent one that has already expired.

In the case of a push notification, this would probably require querying a server to determine what push notifications had previously been sent to the device.

James Holderness
  • 22,721
  • 2
  • 40
  • 52
  • I have the main problem with local notifications. If you lose it, there is no way to recover. – mhergon May 06 '13 at 13:46
  • But you're the one that is initially creating those notifications. When you schedule one, save the `userInfo` property and the `fireDate` in a local database of some sort. – James Holderness May 06 '13 at 13:51
  • Umm, good idea!! But how I know if the user taps notification previously? This is the problem... – mhergon May 06 '13 at 15:23
  • If the user launches the application in response to a notification, the `didFinishLaunchingWithOptions` method will have the `UIApplicationLaunchOptionsLocalNotificationKey` set in the launch options dictionary. But you'll also need to handle the cases where the application is already running (see the [Apple developer documentation](http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW4) for more details). – James Holderness May 06 '13 at 15:37
  • I don't have explained well. `didFinishLaunchingWithOptions:` and `didReceiveLocalNotification:` are working fine. Imagine the following scenario: app is closed and receives a notification. User doesn't opens the notification. Later, user unlock your own device and open the app (without the user open notification). In this point, `didFinishLaunchingWithOptions:` and `didReceiveLocalNotification:` not provides the `userInfo` object – mhergon May 06 '13 at 16:04
  • 1
    If on startup you check your database to see what notifications you've sent in the past, you can tell from looking at the `fireDate` which of them have already been sent, and can assume that the user must have seen them but chosen not to launch the app at the time. – James Holderness May 06 '13 at 16:09