xcode - ios local notification check before fire -
i trying run function every n-minutes when app not running. thing local notification suitable that, have 1 problem.
if set local notification :
-(void)notification{ uilocalnotification *localnotif = [[uilocalnotification alloc] init]; if (localnotif == nil) return; localnotif.firedate = [[nsdate date] datebyaddingtimeinterval:15]; //localnotif.timezone = [nstimezone defaulttimezone]; // notification details localnotif.alertbody = @"marko"; // set action button localnotif.alertaction = @"view"; localnotif.soundname = uilocalnotificationdefaultsoundname; localnotif.applicationiconbadgenumber = 1; // specify custom data notification nsdictionary *infodict = [nsdictionary dictionarywithobject:@"somevalue" forkey:@"somekey"]; localnotif.userinfo = infodict; // schedule notification [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; }
the notification fired every time , do:
- (void)application:(uiapplication *)app didreceivelocalnotification:(uilocalnotification *)notif { nslog(@"recieved notification %@",notif); }
what want after 15s first fire function , if function return yes play sound , put badge on it.
how that?
if application foremost , visible when system delivers notification, no alert shown, no icon badged, , no sound played. however, application:didreceivelocalnotification: called if application delegate implements it.
make sure testing in device.
Comments
Post a Comment