[英]Android Things FCM
I've tried to use FCM with Android Things. 我试过在Android Things上使用FCM。 I've imported the google json, make the changes in Manifest, subscribe the app to a Topic, but I did not receive a push message.
我已导入google json,在Manifest中进行更改,将应用订阅到主题,但我没有收到推送消息。 The only thing I get is the Pushtoken from the server.
我唯一得到的是来自服务器的Pushtoken。
So does anyone successful create an Android Things FCM project? 那么有谁成功创建了Android Things FCM项目?
Thanks! 谢谢!
Here some code snippets: 这里有一些代码片段:
Manifest 表现
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
<uses-library android:name="com.google.android.things" />
<service android:name=".cls_firebase_idservice">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name=".cls_firebase_message">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
MainActivity 主要活动
FirebaseMessaging.getInstance().subscribeToTopic("RaspberryPi3");
Message Receiver 消息接收者
public class cls_firebase_message extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
glo.frm_main.i_handler.sendEmptyMessage(1);
Log.d("RP3", "From: " + remoteMessage.getFrom());
}
}
I got it: I've tried to send the Push over the Firebase Console, which sends a notification, which is not supported. 我明白了:我试图通过Firebase控制台发送Push,它发送一个不受支持的通知。
I have send it over a PHP script which only sends a message and not a notification and now it works. 我已经通过PHP脚本发送它,它只发送消息而不是通知,现在它可以正常工作。
It depends on what sort of message you are sending using the FCM console. 这取决于您使用FCM控制台发送的消息类型。 What you are looking to send is probably a data message but you probably are sending a notification message.
您要发送的内容可能是数据消息,但您可能正在发送通知消息。
Data messages can be created by expanding a data payload window on message creation in the FCM console and putting in some key/value pairs. 可以通过在FCM控制台中创建消息时扩展数据有效负载窗口并放入一些键/值对来创建数据消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.