FCM上游消息到设备组不起作用

时间:2017-04-14 20:50:41

标签: android firebase firebase-cloud-messaging

我正在尝试在用户自己的设备之间发送消息。这就像是对用户自己设备的广播。因此,我创建了一个包含用户设备实例ID的设备组。当我从邮递员发送消息时,用户的两个设备都会收到消息。但是,当我尝试从设备发送消息时,在文档中找到了here

                FirebaseMessaging fm = FirebaseMessaging.getInstance();
                String to = "1234"; // the notification key
                AtomicInteger msgId = new AtomicInteger();
                fm.send(new RemoteMessage.Builder(to)
                      .setMessageId(Integer.toString(msgId.incrementAndGet()))
                      .addData("hello", "world")
                      .build());

我尝试过,notification group keynotification group namerandom number,但没有任何效果。没有错误消息。

另外,我试图通过覆盖onMessageSent方法来检查响应。但它总是返回1。不知道那是什么意思。

我尝试使用FCM的原因是电池效率高,并且不需要与firebase数据库的持久连接。但似乎发送上游消息需要一个中间件来处理所有消息。但是,如果我需要一台服务器来处理所有消息而且我无法托管服务器,那就太棘手了。

我错过了任何基础知识吗?我是gcm / fcm的新手。为什么我的简单代码不起作用并且总是返回1?

0 个答案:

没有答案
相关问题