问题
I have been researching for any possible way to do an alarm app like the app in AppStore (AlarmMon, Rocket Alarm). Which they can alarm with sound continuously even app is in background.
I've tried to turn off their location permission for the case that app using the CLLocationManager to update and extend the backgroundTimeRemaining.
When the alarm is playing sound, It doesn't stop even you receive a phone call (You can accept the call, talk to caller and hear their alarm sound simutaneously).
The VoIP & setKeepAlive is unacceptable by Apple. (Some developer told that their app got rejected when using VoIP)
Playing a silence sound seem to be a goodway for extending an backgroundTimeRemaining, but in the document its mentioned that you shouldn't play a silence sound.
What I've done
- AVFoundation (AVAudioSession, AVAudioPlayer)
- AudioServices (AudioServicesCreateSystemSoundID, AudioServicesCreateSystemSoundID, AudioServicesPlaySystemSoundWithCompletion)
The second way is working fine with playing sound and vibrate the device, but the problem is it cannot be played over 180 seconds (backgroundTimeRemaing).
Key Condition that they said in their app (AlarmMon)
The application cannot be killed by user. If app get killed by user, It will send a loop of a local notification instead. (Local Notification from app is exceed the maximum number that mentioned by Apple (64 times) and It push one by one continuously.)
来源:https://stackoverflow.com/questions/38983753/alarm-like-application