Firebase 推送通知不使用来自 body_loc_key 的 Android 字符串资源

Firebase push notification doesn't use Android string resource from body_loc_key

我有一个后端服务器,可以将云消息推送到 iOS 和 Android 设备。在消息中,body_loc_key 属性设置为 someone_commented_moment,并且 body_loc_args 包含三个字符串参数。 Firebase 文档说 body_loc_key:

On Android, use the key in the app's string resources when populating this value.

在 Android 上,我有一个 strings.xml,其中包含此条目:

<resources>
    [...]
    <string name="someone_commented_moment">
        \@%1$s also commented on \@%2$s\'s moment: %3$s
    </string>
    [...]
</resources>

无论如何,此字符串资源永远不会加载到设备上显示的通知中。

在 iOS 上这完美地工作,并且我确实从通知中获得了启动我的 Activity 的 Intent 中的通知有效负载,所以我想这不是服务器端的错误。我在这里错过了什么吗?我是否必须手动执行某些操作才能使这项工作生效,让 Firebase 找到并使用该字符串资源来本地化通知正文?

编辑: python 触发通知的代码如下所示:

self.fcm.notify_multiple_devices(registration_ids=push_tokens,
                                 body_loc_args=notification.body_loc_args,
                                 message_body=notification.type,
                                 data_message=notification.data,
                                 body_loc_key=notification.type,
                                 sound="default")

其中 self.fcm 是类型 pyfcm.FCMNotification 的对象,并且 notification.type 设置为 "someone_commented_moment",正如打印语句以及获取的内容所确认的那样发送到设备。

好的,我通过手动尝试对 FCM 服务器的不同请求找到了问题所在。如果还设置了 "normal" 消息正文,Android 似乎不会使用 body_loc_key 中的字符串资源 - 我们现在必须让服务器在推送到时省略消息正文Android 设备。