Skip to content

Instantly share code, notes, and snippets.

@an01f01
Created July 23, 2023 14:02
Show Gist options
  • Save an01f01/fc449d4c1927d2676631dd3dd4da2251 to your computer and use it in GitHub Desktop.
Save an01f01/fc449d4c1927d2676631dd3dd4da2251 to your computer and use it in GitHub Desktop.
procedure TFrmMain.FormCreate(Sender: TObject);
begin
{$IFDEF IOS}
if NotificationCenter1.AuthorizationStatus <> TAuthorizationStatus.Authorized then begin
NotificationCenter1.RequestPermission;
end;
{$ENDIF}
{$IFDEF ANDROID}
if NotificationCenter1.AuthorizationStatus <> TAuthorizationStatus.Authorized then begin
NotificationCenter1.RequestPermission;
end;
if PermissionsService.IsPermissionGranted('android.permission.POST_NOTIFICATIONS') <> True then begin
PermissionsService.RequestPermissions(['android.permission.POST_NOTIFICATIONS'],
procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)
begin
if AGrantResults[0] <> TPermissionStatus.Granted then
ShowMessage('Please enable notifications for EMA reminders');
end
);
end;
{$ENDIF}
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment