Firebase云消息未传递到Wear OS设备

时间:2018-07-17 13:59:24

标签: android firebase firebase-cloud-messaging wear-os

我在将Firebase推送消息接收到操作Wear OS的手表时遇到问题。当手表通过蓝牙与智能手机配对时(没有Wi-Fi连接),就会发生这种情况。如果手表上启用了Wi-fi,则可以正常发送消息。

我正在使用FCM端点通过https://fcm.googleapis.com/fcm/send

通过POST请求发送数据消息

消息有效负载本身看起来像这样:

{
    "priority" : "high",
    "to" : "/topics/myTopic",
    "data" : {
        "key1" : "val1",
        "key2" : "val2"
        "key3" : "val3"
    }
}

我像往常一样注册了服务:

    <service android:name=".data.fcm.MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

像往常一样收听消息:

override fun onMessageReceived(remoteMessage: RemoteMessage?) {
        // Check whether message contains a data payload.
        if (remoteMessage?.data!!.isNotEmpty()) {
            Timber.d("Message data payload: ${remoteMessage.data}")
            ....
        }
    }
}

我应该注意,Firebase Database在手表上运行良好,该手表仅通过蓝牙连接到手机。但是FCM不会。

任何想法都会受到赞赏。

1 个答案:

答案 0 :(得分:1)

可能是由于配对电话上FCM使用的端口被阻塞。 如果电话通过Wifi连接,并且FCM端口(5228、5229、5230)在那里被阻止,则消息将不会传递。 https://firebase.google.com/docs/cloud-messaging/concept-options#ports_and_your_firewall

相关问题