Search code examples
iosswiftuilocalnotification

How to make local notification ring continuously when device is locked (swift 3)


I want that my local notification appearing on lock screen should ring continuously until the user taps on it. I'm using date picker to set the time at which notification is arriving, now I want that if the phone is locked, it should ring continuously until the user taps on it just like in alarm app.


Solution

  • This isn't possible, as soon as your app is suspended and goes into the background iOS restricts its memory usage and essentially puts it on pause and it's not allowed to do anything until the user brings it to the foreground again.

    There are supported background modes for audio, location updates, background fetch etc. (refer to iOS Background modes)

    But none of these will allow you to do what you want, the alarm feature is an ability exclusive to Apple and I don't see it changing anytime soon I'm afraid.

    Your only hope is to use push notifications or local notifications.