Skip to content

Commit 4b12869

Browse files
author
Dave Nottage
committed
Add category support for Android
1 parent 7af72b4 commit 4b12869

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Features/Firebase/DW.FCMManager.Android.pas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ TPlatformFCMManager = class(TCustomPlatformFCMManager, IFCMManager)
9595
protected
9696
function CanHandleNotification(const AServiceNotification: TPushServiceNotification): Boolean; override;
9797
procedure CreateChannel; override;
98+
procedure ReceiveNotification(const AServiceNotification: TPushServiceNotification); override;
9899
public
99100
constructor Create;
100101
destructor Destroy; override;
@@ -241,6 +242,16 @@ procedure TPlatformFCMManager.CheckPushEnabled(const AHandler: TCheckPushEnabled
241242
AHandler(IsAndroidPushEnabled);
242243
end;
243244

245+
procedure TPlatformFCMManager.ReceiveNotification(const AServiceNotification: TPushServiceNotification);
246+
var
247+
LAction: string;
248+
LCategory: INotificationCategory;
249+
begin
250+
AServiceNotification.Json.TryGetValue('click_action', LAction);
251+
if AServiceNotification.Json.TryGetValue('click_action', LAction) and FindCategory(LAction, LCategory) then
252+
LCategory.Handler();
253+
end;
254+
244255
procedure TPlatformFCMManager.RemoveNotifications;
245256
var
246257
LNotifications: TJavaObjectArray<JStatusBarNotification>;

Features/Firebase/DW.FCMManager.pas

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ TCustomPlatformFCMManager = class(TInterfacedObject)
195195
procedure DoStart;
196196
function FindCategory(const AID: string; out ACategory: INotificationCategory): Boolean;
197197
procedure HandleNotification(const AServiceNotification: TPushServiceNotification);
198+
procedure ReceiveNotification(const AServiceNotification: TPushServiceNotification); virtual;
198199
procedure Started;
199200
property Categories: TNotificationCategories read FCategories;
200201
property IsForeground: Boolean read FIsForeground;
@@ -622,6 +623,11 @@ procedure TCustomPlatformFCMManager.HandleNotification(const AServiceNotificatio
622623
ReceiveNotificationHandler(Self, AServiceNotification);
623624
end;
624625

626+
procedure TCustomPlatformFCMManager.ReceiveNotification(const AServiceNotification: TPushServiceNotification);
627+
begin
628+
//
629+
end;
630+
625631
procedure TCustomPlatformFCMManager.ReceiveNotificationHandler(Sender: TObject; const AServiceNotification: TPushServiceNotification);
626632
begin
627633
if Assigned(FOnNotificationReceived) then
@@ -630,6 +636,7 @@ procedure TCustomPlatformFCMManager.ReceiveNotificationHandler(Sender: TObject;
630636
begin
631637
if Assigned(FOnMessageReceived) and CanHandleNotification(AServiceNotification) then
632638
FOnMessageReceived(Self, AServiceNotification.Json);
639+
ReceiveNotification(AServiceNotification);
633640
end;
634641
end;
635642

0 commit comments

Comments
 (0)