FMX.SetResetBadgeNumber Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample demonstrates how to set the application icon badge number on iOS devices.

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

  1. Navigate to one of the locations given above and open:
    • Delphi: SettingResettingBadgeNumber.dproj.
    • C++: SettingResettingBadgeNumber.cbproj.
  2. Select the iOS platform in the Projects Window.
  3. Press F9 or choose Run > Run.

Files

File in Delphi File in C++ Contains

SettingResettingBadgeNumber.dproj
NativeControlsDemo.dpr

SettingResettingBadgeNumber.cbproj
SettingResettingBadgeNumber.cpp

The project itself.

uMain.pas
uMain.fmx

uMain.h
uMain.cpp
uMain.fmx

The main form.

Classes

TSettingBadgeNumberForm is the main form that represents the main window of the sample. It contains the following components:

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

Samples