ios - Trigger local notification on applicationDidBecomeActive -


i'm developing alarm app using uilocalnotification object. in code, when alarming , users click notification panel, app show view controller. added codes in different life cycles below satisfying situation:

  1. when alarming up, app in foreground,
  2. the app in background , users click notification panel trigger app,
  3. the app killed , users click notification panel trigger app.

when alarming up, if users click app icon trigger instead of clicking notification panel, function not triggered in didreceivelocalnotification. how code satisfy situation?


for triggering notification if app killed, ios can check scheduled notifications automatically , response in launchoptions object

-(bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{      [self registernotification];          uilocalnotification *localnotification =        [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey];     if (localnotification) {         // launch videovc         application.applicationiconbadgenumber = 0;         [application presentlocalnotificationnow:localnotification];     } } 

for launch custom function when users click on notification

-(void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification{      [self launchmyfunction] } 

if user click app icon instead of notification panel when alarms triggered, didreceivelocalnotification not triggered

- (void)applicationdidbecomeactive:(uiapplication *)application {      // how trigger notification?????? } 

i use badge number solve it. members replied questions inspire me.

- (void)applicationdidbecomeactive:(uiapplication *)application {      if([uiapplication sharedapplication].applicationiconbadgenumber > 0){         [self myfunction];     } } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -