You can find the SendCancelNotification sample project at:
- Start | Programs | Embarcadero RAD Studio Rio | Samples and then navigate to:
Object Pascal\Mobile Snippets\Notifications\SendCancelNotification
- Subversion Repository:
With this sample, you can do the following:
- Send notifications immediately.
- Send scheduled notifications.
- Cancel scheduled notifications.
- Cancel all notifications.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: SendCancelNotifications.dproj.
- C++: SendCancelNotifications.cbproj.
- Select the target platform, iOS, Android, and OS X supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Click Send Scheduled Notifications to schedule a notification to be fired in 10 seconds.
- Click Send Notification Immediately to send a notification immediately.
- Click Cancel Scheduled to cancel the scheduled notification.
- Click Cancel All Notifications to cancel all notifications.
|File in Delphi||File in C++||Contains|
The project itself.
The main form where the components are located.
Used to define and implement the sample.
Further information about the sample.
The TNotification component is the notification itself.
After creating the notification, the sample sets the following notification details:
- The Name field uniquely identifies a notification.
- The AlertBody field adds the text of the notification.
- Immediate Notifications: The sample sets the FireDate to Now for notifications that need to be fired immediately.
- Scheduled Notifications: To fire the notification in 10 seconds, the sample sets the FireDate to the current system time and then uses EncodeTime to add 10 seconds to the current time.
- Warning: Windows does not support ScheduleNotification.
After adding the information for the notification and adding the scheduling information, the sample uses the following sentence to send the notification to the notification center.
The following sentence is equivalent for immediate notifications, and you may also use
PresentNotification to send notifications to the notification center when they have to be fired immediately.
- Tip: Windows does not support scheduled notifications, you can present immediate notifications in Windows with
The sample uses CancelAll to cancels all notifications:
- The notifications that are scheduled will not be fired.
- The notifications, that belong to this application, and are available in the notification center or notification drawer are also cancelled and removed.
- Using Notifications
- Mobile Tutorial: Using Notifications (iOS and Android)
- Using the OS X Notification Center