FMX.SetResetBadgeNumber Sample
This sample demonstrates how to set the application icon badge number on iOS devices.
Contents
Location
You can find the SetResetBadgeNumber sample project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
Object Pascal\Mobile Snippets\Notifications\SetResetBadgeNumber
CPP\Mobile Snippets\Notifications\SetResetBadgeNumber
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
The SetResetBadgeNumber sample shows you how to use the Notification API in order to set the badge number on the application icon on iOS devices to a specified value or to reset the badge number to 0.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi:
SettingResettingBadgeNumber.dproj
. - C++:
SettingResettingBadgeNumber.cbproj
.
- Delphi:
- Select the iOS platform in the Projects Window.
- Press F9 or choose Run > Run.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
|
|
The project itself. |
|
|
The main form. |
Classes
TSettingBadgeNumberForm is the main form that represents the main window of the sample. It contains the following components:
- A TNotificationCenter object.
- A TListBox object with a ListBox Item that contains:
- Two TButton objects named btnBadgeNumberDown and btnBadgeNumberUp.
- A TNumberBox object.
- A ToolBar object that contains:
- Two TButton objects named btnResetBadgeNumber and btnSetBadgeNumber.
- A TLabel object.
Implementation
- The sample uses TNotificationCenter to allow the user to access the notification service.
- The sample uses TButton to enable or activate a function such as set or reset the badge number.
When you run the aplication, you see the TNumberBox object set to 0
. This is the badge number of the application. To increase the badge number, use the buttons btnBadgeNumberDown and btnBadgeNumberUp. To increase the badge number, click on the btnBadgeNumberUp button. To decrease the badge number, click on the btnBadgeNumberDown button. Once the badge number is set to the desired one, if you click on the btnSetBadgeNumber button, the sample uses the ApplicationIconBadgeNumber property of
TNotificationCenter to update the application badge number. Finally, if you click on btnResetBadgeNumber button, the application badge number is reset to 0
.
Uses
See Also
- Using Notifications
- Mobile Tutorial: Using Notifications (iOS and Android)
- Using the macOS Notification Center
Samples
- FireMonkey Send Cancel Notification sample
- FireMonkey Notification Mac (Delphi)
- FireMonkey Notification Mac (C++)
- OSX Dock Badges (Delphi)