ios - Does launchOptions 'UIApplicationLaunchOptionsLocalNotificationKey' contain NSDictionary or UILocalNotification -
ok, i've read various articles on how check local notifications in didfinishlaunchingwith options. example nshipster article claims remote , local keys both contain nsdictionary. http://nshipster.com/launch-options/
however, tested , contains uilocalnotification, , other articles says well.
so, i've looked around not found definitive answer. os version issue? different versions contain different objects, or what?
pointers appreciated.
edit:
from nshipster article:
"a local notification populates launch options on uiapplicationlaunchoptionslocalnotificationkey, contains payload same structure remote notification:
uiapplicationlaunchoptionslocalnotificationkey: indicates local notification available app process. value of key nsdictionary containing payload of local notification."
according apple documentation, uiapplicationlaunchoptionslocalnotificationkey give uilocalnotification object.
if default action button tapped (on device running ios), system launches app , app calls delegate’s application:didfinishlaunchingwithoptions: method, passing in notification payload (for remote notifications) or local-notification object (for local notifications). although application:didfinishlaunchingwithoptions: isn’t best place handle notification, getting payload @ point gives opportunity start update process before handler method called.
sample code apple docs
- (bool)application:(uiapplication *)app didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { uilocalnotification *localnotif = [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey]; if (localnotif) { nsstring *itemname = [localnotif.userinfo objectforkey:todoitemkey]; [viewcontroller displayitem:itemname]; // custom method app.applicationiconbadgenumber = localnotif.applicationiconbadgenumber-1; } [window addsubview:viewcontroller.view]; [window makekeyandvisible]; return yes; }
edit: update uiapplicationlaunchoptionsremotenotificationkey
uiapplicationlaunchoptionsremotenotificationkey
, returns nsdictionary notification payload
Comments
Post a Comment