Sending local notifications after the app has been terminated

10,041

Solution 1

Sure it is possible, if you schedule a local notification it will fire even if you terminate the app.

        UILocalNotification *_localNotification = [[UILocalNotification alloc] init];
        _localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:_value];
        _localNotification.timeZone = [NSTimeZone defaultTimeZone];
        _localNotification.alertBody = @"Beep... Beep... Beep...";
        _localNotification.soundName = UILocalNotificationDefaultSoundName;
        [[UIApplication sharedApplication]scheduleLocalNotification:_localNotification];

... works like a charm for me.

Solution 2

The local notification can be delivered when the app is terminated or closed, but they must be scheduled when the app is running. You can set the fireDate for a notification in the future, schedule it, and it will be delivered whether or not the app is running.

Share:
10,041
Henry Brown
Author by

Henry Brown

Updated on June 08, 2022

Comments

  • Henry Brown
    Henry Brown almost 2 years

    I am making an app in iOS where it will send local notifications on a timer. It works fine when the app is in background state, but does not work when it has been terminated and closed completely.

    Is there anyway to still send local notifications when this has happened?

    Thanks in advance.