PJS
PJS

Reputation: 151

How to handle Firebase FCM click_action in Delphi firemonkey android?

I am able to reproduce the same android app using Delphi 10.3.2 follow the steps in https://community.idera.com/developer-tools/b/blog/posts/firebase-android-push-notification-support-with-rad-studio-10-3-1

which receive the firebase push notification, however, I found no clue to handle the FCM click_action when user click the notification.

I tried add an additional intent-filter action android:name="CUSTOM_ACTION" to the androidmanifest.xml

    <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
            android:label="ione"
            android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
            android:launchMode="singleTask">
        <!-- Tell NativeActivity the name of our .so -->
        <meta-data android:name="android.app.lib_name"
            android:value="ione" />
        <intent-filter>  
            <action android:name="android.intent.action.MAIN" />
            <action android:name="CUSTOM_ACTION" />             
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter> 

    </activity>

and use MainActivity.registerIntentAction(StringtoJString('CUSTOM_ACTION'));

to register the intent action and test.

If I include the click_action in FCM notification, when user click on the notification, nothing happen. If I remove the click_action, the app will be opened when user click on the notification.

Anyone know how should we configure in Delphi to handle the FCM click_action ?

Upvotes: 1

Views: 1191

Answers (1)

Dave Nottage
Dave Nottage

Reputation: 3612

Example of how to handle it:

constructor TForm1.Create(AOwner: TComponent);
var
  LPushData: TPushData;
begin
  inherited;
  LPushData := PushEvents1.StartupNotification;
  if LPushData <> nil then
    PushEvents1PushReceived(PushEvents1, LPushData);
end;

Upvotes: 1

Related Questions