我有一个Android和iOS应用程序,设置为接收FCM主题消息 .
在启动时,我订阅了一个名为top_stories的主题 . 一个人取消订阅的唯一时间是他们切换应用程序中的设置以接收通知 .
我们通过我们自己的服务器使用FCM API发送推送消息,并且有效负载包含通知和数据主体有效负载 .
我们最近开始发送主题并注意到一些问题 . 在90%的情况下,我们所有的办公室测试设备都接受了推送 . 然而,一些iOS设备和一些Android设备有不同的体验 .
其中两个iOS设备没有收到第一条和第二条消息,但确实收到了第三条消息 .
类似的事情发生在一个Android设备上,它接收到第一个消息,没有收到第二个消息,并确实收到第三个消息 .
我有什么办法可以改善/解决这种情况吗?
我可以根据需要提供有关示例消息等的更多详细信息 .
我知道onMessageReceived在所有情况下都能正常运行,因为它在我们的内部测试中起作用 .
我们使用以下库来构建消息:
https://github.com/sngrl/php-firebase-cloud-messaging
这是构建消息的代码:
object(sngrl\PhpFirebaseCloudMessaging\Message)[505]
private 'notification' =>
object(sngrl\PhpFirebaseCloudMessaging\Notification)[503]
private 'title' => string 'App Name' (length=14)
private 'body' => string 'Upgrade testing - activation' (length=36)
private 'badge' => null
private 'icon' => null
private 'sound' => string 'default' (length=7)
private 'clickAction' => null
private 'tag' => null
private 'content_available' => boolean true
private 'notification' (sngrl\PhpFirebaseCloudMessaging\Message) => null
private 'collapseKey' (sngrl\PhpFirebaseCloudMessaging\Message) => null
private 'priority' (sngrl\PhpFirebaseCloudMessaging\Message) => null
private 'data' (sngrl\PhpFirebaseCloudMessaging\Message) => null
private 'recipients' (sngrl\PhpFirebaseCloudMessaging\Message) =>
array (size=0)
empty
private 'recipientType' (sngrl\PhpFirebaseCloudMessaging\Message) => null
private 'jsonData' (sngrl\PhpFirebaseCloudMessaging\Message) =>
array (size=0)
empty
private 'collapseKey' => null
private 'priority' => string 'high' (length=4)
private 'data' =>
array (size=7)
'v' => int 1484232738
'timestamp' => int 1484232738
'pushId' => string '58779822a1fef' (length=22)
'content_available' => boolean true
'title' => string 'Upgrade testing - activation' (length=36)
'articleId' => int 250324509
'category' => string 'news/' (length=5)
private 'recipients' =>
array (size=1)
0 =>
object(sngrl\PhpFirebaseCloudMessaging\Recipient\Topic)[504]
private 'name' => string 'top_stories_test' (length=16)
private 'to' (sngrl\PhpFirebaseCloudMessaging\Recipient\Recipient) => null
private 'recipientType' => string 'sngrl\PhpFirebaseCloudMessaging\Recipient\Topic' (length=47)
private 'jsonData' =>
array (size=0)
empty
{
"to" : "/topics/top_stories",
"priority" : "high",
"notification" : {
"body" : "Article Title",
"title" : "Publication Name",
"sound" : "default"
},
"data" : {
"title" : "Article Title",
"v" : "1484232738",
"timestamp" : "1484232738",
"pushId" : "fireabse-58779822a1fef",
"content_available" : true,
"title" : "Article Title",
"articleId" : "12345",
"category" : "news/"
}
}
compile "com.google.firebase:firebase-messaging:10.0.1"
<service
android:name="ie.company.services.MyInstanceIDListenerService"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name="ie.company.services.MyFcmListenerService"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>