开发者

No APNS launchoptions if launched later?

my APNS notification works fine, but I have noticed a strange behavior for which I would like to ask for confi开发者_开发技巧rmations.

I'm retrieving the notification payload either during "didFinishLaunchingWithOptions" or "didReceiveRemoteNotification". In "didFinishLaunchingWithOptions" I'm checking

NSDictionary* userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

in order to derive the parameters. In "didReceiveRemoteNotification" the apsInfo is derived from NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

This works fine, with one exception: If I ignore the notification popup and tap "Close" instead of "View" and finally launch my app later on from the launchpad, there is no apsInfo anymore. Is this "by design"? Is the notification info only available, if one hits "View" or launches the app from the notification info dialog?

Regards


The same problem. Notification arrived on phone and user pressed Close instead of View on message box. A badge appear on app icon. Well done. Now, open the app and as Apple's documentation says: "use didFinishLaunchingWithOptions when you want launchOptions filled with notification and bla, bla..."

The problem is, that when didFinishLaunchingWithOptions is fired launchOptions is still empty.

Tried many combinations of solution: no result. SDK's bug?

UPDATE ===================================== In Apple's documentation is in didFinishLaunchingWithOptions written: "The dictionary is nil if the user launched the application by tapping the application icon."

So, I have no idea if it even possible to retrieve body of notification when app is launched after user closed notification messagebox (and there's badge on app icon). Is notification body lost in space when user closes notification messagebox? UPDATE======================================= After further investigation I found answer. Yes, non-delivered data are lost. No waiting for user to be online, no storage, no info of notification delivering. APNS in not payed service and Apple has no responsibility for 100% delivering of data.


Seems, this is the way, it is. I guess, we are all supposed to contact our servers in order to retrieve the notification payload (again). This is rather rediculous, because a notification payload is not more than 256 byte, so Apple could have provided a means to keep the notification payload for later use. At least you can retrieve the information sent to you in the "badge" element. This is saved. The rest is lost, sadly...


I have an idea, though I do not have the time to implement it at the moment.

  1. When you send a Push Notification, record in your web server's database each user that was sent the Notification.

  2. The next time any given user opens the app (could be directly from the Push Notification or later via tapping the app's icon), you ping your server to see if that user has opened the app since the Push Notification was sent.

  3. If this is the first time that the user has opened the app since the Notification was sent, your app reads the appropriate data from your server and kicks into whatever state you want.

Just an idea at this point, but I think it will work. Just depends if it is worth your time to implement it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜