【问题标题】:FCM notification "click_action" not workingFCM 通知“click_action”不起作用
【发布时间】:2021-02-09 17:21:27
【问题描述】:

我正在使用云函数并使用它发送推送通知。发送通知按预期工作,但 click_action 属性不起作用。当我单击通知时,没有任何反应。这是我的代码:

我的通知负载:

const payload = {
  notification: {
      title: 'Soru Çözüm',
      body: 'Attığınz soruya bir yorum geldi: ' + data.content,
      icon: 'ic_stat_logo',
      click_action: '.activities.SoruDetayActivity'
  },
  data: {
      title: 'Soru Çözüm',
      content: 'Sorunuz çözüldü.',
      post: data.parent
  }
};

意图过滤器:

<activity
    android:name=".activities.SoruDetayActivity"
    android:label="Soru"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <action android:name=".activities.SoruDetayActivity"/>

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="www.website.com"
            android:scheme="https" />
    </intent-filter>
</activity>

【问题讨论】:

  • 你能解决这个问题吗?我有同样的问题:/

标签: android google-cloud-functions firebase-cloud-messaging


【解决方案1】:

您的通知有效负载似乎正确。 尝试通过删除 data 和 category.BROWSABLE 标记来更改您的意图过滤器,如下面的代码行:

<activity
    android:name=".activities.SoruDetayActivity"
    android:label="Soru"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <action android:name=".activities.SoruDetayActivity"/>

        <category android:name="android.intent.category.DEFAULT" />
       
    </intent-filter>
</activity>

【讨论】:

    【解决方案2】:

    Notification 将尝试启动 URL,指定的活动名称不符合 URL,因此 Android 不会执行任何操作,因为它无法识别,而是如果您使用 @ 中提到的 host 地址Manifest 中的 987654323@ 标记,它应该将您重定向到该 Activity,如下所示

    click_action: 'https://www.website.com'
    

    【讨论】:

    • 输入“click_action”属性的 URL 也不起作用。仍然没有任何反应。
    • 您是否尝试过使用实际的数据方案?我想https://www.website.com 就是一个例子
    【解决方案3】:

    您的操作名称应该是要启动的活动的全名。您现在拥有的是部分名称,相对于您的应用程序包的名称。我们看不到这里是什么,因为前缀在您的清单中的其他地方。一旦你找到它,它应该看起来更像这样:

      click_action: 'com.yourapp.activities.SoruDetayActivity'
    

    【讨论】:

    • 道格 - 你真的试过这个吗?我遇到了同样的问题,提供全名似乎没有帮助。从其他帖子看来,这里的字符串值与清单中的 name= 值匹配就足够了(但这对我也不起作用)。
    猜你喜欢
    • 1970-01-01
    • 2022-08-15
    • 2016-09-21
    • 1970-01-01
    • 2023-03-16
    • 2020-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多