Add Notification Center to both sender and receiver apps.
Simple
Notification := NotificationCenter.CreateNotification;
try
Notification.Name := 'MyNotification';
Notification.AlertBody := 'Delphi for Mobile is here!';
Notification.FireDate := Now;
{ Send notification in Notification Center }
NotificationCenter.PresentNotification(Notification);
{ also this method is equivalent if platform supports scheduling }
//NotificationCenter.ScheduleNotification(Notification);
finally
Notification.DisposeOf;
end;
Add Notification Center to a Service module and show an ongoing notification required in the latest Android for "Services" running in the foreground.
Use https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder to Build the notification.
init Changes between Berlin and Sydney
Init Sydney
Builder := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context, StringToJString(NotificationChannelId));
Init Berlin
Builder := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context);
Builder Functions
Use setContentIntent to include the intent used to start the native activity after the user taps on the ongoing notification.
Use AddAction to include the intent used to provide activate an additional action by pressing on text in the notification.
SetPriority(TJNotification.JavaClass.PRIORITY_HIGH);
setOngoing(True);
setSmallIcon GetIconId Integer
setContentTitle StrToJCharSequence(NotificationTitle) {Limited Chars}
setContentText StrToJCharSequence(NotificationContent) (Limit about 36 Chars)
setTicker Sets the "ticker" text which is sent to accessibility services.
setWhen Time of notification eg. TJDate.Create.getTime;