FMX.SetResetBadgeNumber Sample

From Appmethod 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:

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:
    • Object Pascal: SettingResettingBadgeNumber.dproj.
    • C++: SettingResettingBadgeNumber.cbproj.
  2. Select the iOS platform in the Project Manager.
  3. Press F9 or choose Run > Run.

Files

File in Object Pascal 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