How can I schedule a local (no server) PUSH notification (not an alert) to fire from my app? I simply want to schedule a notification from my app and have it fire at the given time in the notification center. I have tried to use LocalNotifications but they only seem to work if the app is open, and only update the badge if it is closed. I also see no way of sending push notifications unless you use a server.
Currently I can schedule a LocalNotification and have an alert pop up, but I would like this to work when the app is closed, and instead of an alert, I would like a push notification that pops up at the top.
Notification permission should be requested as soon as the app launches by adding the following code to the
FinishedLaunching
method of theAppDelegate
and setting the desired notification type (UNAuthorizationOptions
):New to iOS 10, an app can handle Notifications differently when it is in the foreground and a Notification is triggered. By providing a
UNUserNotificationCenterDelegate
and implementing theUserNotificationCentermethod
, the app can take over responsibility for displaying the Notification. For example:To create and register a Custom Action with the system, use the following code:
When you call this method ,for emample:
The notification will been pushed after 20 seconds,enen if you close your app.
I have upload my demo to my github, you can download it for your reference: Demo Link .
And you can access the link for more information and details: MicroSoft Document
try this it will create a local notification after 5 second but if you want repetitive then increase the time more then 60
write this in your app delegate
and in your view controller
}