ios - Alarm is not ringing after 3 minutes when its running in background -


i working on alarm application. faced problem last 2 weeks. problem is: application running in background.first time install application , set alarm & close app. if alarm time more 3 minutes current time not ringing means after 3 min alarm not ringing in background process. if application on alarm working.

this code:

   self->bgtask = 0;    nsassert(self->bgtask == uibackgroundtaskinvalid, nil);     bgtask = [application beginbackgroundtaskwithexpirationhandler: ^    {        nslog(@"beginbackgroundtaskwithexpirat");        dispatch_async(dispatch_get_main_queue(), ^        {            nslog(@"dispatch_async");            [application endbackgroundtask:self->bgtask];            self->bgtask = uibackgroundtaskinvalid;        });    }];     dispatch_async(dispatch_get_main_queue(), ^    {        nslog(@"dispatch_get_main_queue");        //start bg timer     [self start_update_timer];        self->bgtask = uibackgroundtaskinvalid;    });  // timer background running ..  -(void) start_update_timer   {         //if timer running, stop timer        if(self.calltimer)        {           [self.calltimer invalidate];           self.calltimer=nil;        }     //call timer every 1 sec    self.calltimer =[nstimer scheduledtimerwithtimeinterval:60 target:self selector:@selector(update_alarm_list) userinfo:nil repeats:yes];       [[nsrunloop mainrunloop] addtimer:self.calltimer formode:nsrunloopcommonmodes];    } 

because applications not supposed work this. if want app continuously play sound on background, should registered app specially. music player. if app delivers alarms, have use local notification "trigger" sound app. notification can played 30 secs sound , replay again @ intervals. app wont play after 3 minutes because "background" execution time has expired. time apple lets app run in background whatever have after user has closed application.

this case in want keep playing sound on background. note if playback stops app stop.

https://developer.apple.com/library/ios/qa/qa1668/_index.html#//apple_ref/doc/uid/dts40010209

if want use notifications sound (30 secs max) see here:

https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/remotenotificationspg/chapters/iphoneosclientimp.html


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -