See demo of the Day
The demo is detailed in the following description:
To set an alarm:
1. Notification time is not reached, click the app to enter directly, the notification time, the alarm clock does not sound (the alarm is not exited the program is also the case)
1.1 Solve this problem first through the notification time to call the proxy method, add an audio avfoundation, set to play;
1.2 Then another problem is that the alarm clock conflict is if the lock screen or exit the app after the notification, click on the notification to enter the program, (the system default notification of the music automatically stopped, but the proxy method set by the player will still start playing)
1.3 How to solve the above methods:
Set a global switch (that is, flag) and set flag to on if the program exits or is about to enter the foreground to keep the main program player playing
Another proxy method in the app applicationdidbecomeactive flag is set to off no, the execution time of this method is fixed, and after the program is activated,
However, it becomes the proxy method of notification (notification time to immediate execution), so if you swipe (lock screen) or click (Unlocked) to notify the app to immediately execute the notification agent method, and then go applicationdidbecomeactive method to set flag to no, because the incoming reception is set flag to Yes, the notification time has been to start the notification agent method, and the activation method has not been executed, at this time the alarm can ring.
This is the idea, for the convenience of everyone to see the effect, want to see the original code please leave the email to everyone.
This is the idea, for the convenience of everyone to see the effect, want to see the original code please leave the mailbox sent to everyone or add QQ.
ios-Notice: Alarm about setting the alarm, click the app icon to enter the program does not play music issues (resolved)