Manipulating the icon badge numbers from an iOS FireMonkey application

Posted by on in Blogs
Q: How do I update those little numeric indicators on my app's icon to show how many notifications the user should have?
A: By using setApplicationIconBadgeNumber

Very simple unit that increments the icon badge number below.

Enjoy!

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
{$IFDEF FPC}
UIApplication.sharedApplication.setApplicationIconBadgeNumber(UIApplication.sharedApplication.applicationIconBadgeNumber+1);
{$ENDIF}
end;

end.



Comments

Check out more tips and tricks in this development video: