首页 > 解决方案 > 如何在 Delphi firemonkey android 中处理 Firebase FCM click_action?

问题描述

我可以使用 Delphi 10.3.2 重现相同的 android 应用程序,按照 https://community.idera.com/developer-tools/b/blog/posts/firebase-android-push-notification-support-with-中的步骤操作辐射工作室 10-3-1

接收firebase推送通知,但是,当用户单击通知时,我没有发现处理FCM click_action的线索。

我尝试向 androidmanifest.xml 添加一个额外的意图过滤器操作 android:name="CUSTOM_ACTION"

    <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>

并使用 MainActivity.registerIntentAction(StringtoJString('CUSTOM_ACTION'));

注册意图动作和测试。

如果我在 FCM 通知中包含 click_action,当用户单击通知时,什么也不会发生。如果我删除 click_action,当用户点击通知时,应用程序将被打开。

任何人都知道我们应该如何在 Delphi 中配置来处理 FCM click_action ?

标签: delphiclickfirebase-cloud-messagingactionrad-studio

解决方案


如何处理它的示例:

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

推荐阅读