There are two ways for your app to notify the user while the app is in the background: push notifications and local (or scheduled) notifications.
This tutorial explains how to create local notifications. Local notifications are simple to use but are also quite limited. While your app is running you can schedule one or more notifications to run.
When the notification runs the user will see a small alert box. If the user will press on the alert box then your app will be started. You can also set a badge number on the app icon.
This video demonstrates this type of notifications. In this example the notification fires in 6 seconds so it is a bit quick. First a notification arrives while the app is running causing the Application_ReceiveLocalNotification event to fire.
In the second case the app is killed and then the notification arrives.
In this case the notification information can be extracted from App.LaunchOptions Map (see the example code):
Before you can show a notification you need to ask the user for permission. This is done by calling App.RegisterUserNotifications. On the first run the user will be asked to allow your app to use these features.
The next step is to create a notification object and call Notification.Register.
Tips:
- You can get the scheduled notifications with App.GetScheduledNotifications.
- You can cancel all scheduled notifications with App.ClearLocalNotifications.
- Only in Release mode you can actually start the app from a notification.
This tutorial explains how to create local notifications. Local notifications are simple to use but are also quite limited. While your app is running you can schedule one or more notifications to run.
When the notification runs the user will see a small alert box. If the user will press on the alert box then your app will be started. You can also set a badge number on the app icon.
This video demonstrates this type of notifications. In this example the notification fires in 6 seconds so it is a bit quick. First a notification arrives while the app is running causing the Application_ReceiveLocalNotification event to fire.
In the second case the app is killed and then the notification arrives.
In this case the notification information can be extracted from App.LaunchOptions Map (see the example code):
Before you can show a notification you need to ask the user for permission. This is done by calling App.RegisterUserNotifications. On the first run the user will be asked to allow your app to use these features.
The next step is to create a notification object and call Notification.Register.
Tips:
- You can get the scheduled notifications with App.GetScheduledNotifications.
- You can cancel all scheduled notifications with App.ClearLocalNotifications.
- Only in Release mode you can actually start the app from a notification.
Attachments
Last edited: