ios8 - iOS 8 custom alarm using uilocalnotification and playing sound in background when phone is on silent -


i trying build custom alarm application. challenge facing getting sound played while app in background.

first method, uilocalnotification,

according apple programming guidelines, right way make alarm is

- (void)schedulealarmfordate:(nsdate*)thedate {     uiapplication* app = [uiapplication sharedapplication];     nsarray*    oldnotifications = [app scheduledlocalnotifications];      // clear out old notification before scheduling new one.     if ([oldnotifications count] > 0)         [app cancelalllocalnotifications];      // create new notification.     uilocalnotification* alarm = [[uilocalnotification alloc] init];     if (alarm)     {         alarm.firedate = thedate;         alarm.timezone = [nstimezone defaulttimezone];         alarm.repeatinterval = 0;         alarm.soundname = @"alarmsound.caf";         alarm.alertbody = @"time wake up!";          [app schedulelocalnotification:alarm];     } } 

problem is,

  • if user has phone on silent, notification sound small vibrate doesn't suffice alarm.

  • idealy, want alarm go off no matter phone on silent or normal wake user.

second way can think of, avaudiosession

  • but when region near or alarm trigger comes in, audiosession cannot initiated in background audioplayer.play() methods won't anything.

besides above 2 methods both don't work, can't seem find other ways tackle problem @ hand.

i trying make app location based alarm.

  • i can set region , custom sound 30 seconds on uilocalnotification sound won't play if phone silent.

  • i can have locationmanager monitoring region can't play sound after notified background.

i've downloaded many apps capable of doing know there must way of achieving it. however, after multiple tries in various angles, can't seem find solutions. if had experience making custom alarm, please share tips , pointers if can.

thank you.

since reputation not enough comment everywhere, write here answer. sorry this.

i'm suffering same problem. though cannot give solution, there might hints you. me, think might impossible achieve.

i have double checked 2 alarm application use: sleep cycle , uniqlo wake up. , found out these 2 applications asked keep running on foreground make sure alarm clock work. uniqlo wake up, show alert when save alarm clock, telling press home button may cause alarm clock not working.

there post asking similar question, , author provide names of applications: how start playing audio when in silent mode locked in ios 6. checked application called wavealarm. similarly, if cellphone in mute mode , put background, uilocalnotification work. means, no sound played in situation. if cellphone still in mute mode, keep application in foreground, play sound. volume of sound depends on volume set video playing.

so me, think might impossible play alarm sound when put application background , set cellphone mute mode. guess possible way achieve ask users keep in foreground, , play media alarm sound.

i'll try achieve function in these 2 days. if have other understandings, i'll edit post here.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -