iphone - Notification method IOS xcode 5 -


i have notification set fire on fire date/time date picker. run method when happens, there way @ time of notification?

here code

-(void)schedulelocalnotificationwithdate:(nsdate *)firedate{      uilocalnotification *notification = [[uilocalnotification alloc]init];      notification.firedate = firedate;     notification.alertbody = @"time hit";     notification.soundname = @"alarmsoundfile.mp3";       [[uiapplication sharedapplication]schedulelocalnotification:notification]; } 

at first should set info identify group of notifications (in case use local notifications in future). also, example, can set time interval since 1970 fire date id:

notification.userinfo = @{@"group" : @"time hit",                           @"id" : @(firedate.timeintervalsince1970)}; 

then receive notifications in appdelegate:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     uilocalnotification *localnotification = [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey];     if (localnotification) {         [self application:application didreceivelocalnotification:localnotification];     }     return yes; }  - (void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification {     nsdictionary *userinfo = notification.userinfo;     if ([(nsstring *)userinfo[@"group"] isequaltostring:@"time hit"]) {         // actions here     } } 

note: far know, can receive notification if application foreground @ fire date or if launch/enter foreground fired notification


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -