在此处尝试了推送通知示例:http://docs.gluonhq.com/samples/pushnotes/。在此处参考API:http://docs.gluonhq.com/charm/javadoc/4.3.0/com/gluonhq/charm/down/plugins/PushNotificationsService.html,并在此处参考一些帮助:creating push notifications in android using javafx
我有Firebase推送通知帐户,并按照步骤创建了发件人ID,并按照示例中指定的代码进行了设置。
我还将Firebase提供的google-services.json复制到了项目目录下。
已将示例中的Android清单中的所有内容(接收方,服务,活动)完全复制到自己的清单文件中。
这被添加到postinit方法中:
String sender_id = "163xx...";
PushClient pushClient = new PushClient();
pushClient.enable(sender_id);
Services.get(RuntimeArgsService.class).ifPresent(ras -> {
ras.addListener(RuntimeArgsService.LAUNCH_PUSH_NOTIFICATION_KEY, f -> {
System.out.println("Received a push notification with contents: " + f);
});
});
Services.get(PushNotificationsService.class).ifPresent(service -> {
service.register(sender_id);
service.tokenProperty().addListener((obs, ov, nv) -> {
System.out.println("Device token: " + nv);
});
});
但是,当我启动应用程序时,出现此错误:
06-25 23:53:43.494: W/System.err(31439): java.lang.IllegalStateException: Invalid CloudLink configuration detected. Please verify that you have correctly added your Gluon CloudLink Application configuration file at src/main/resources/gluoncloudlink_config.json. The correct configuration file can be downloaded from the Gluon Dashboard at https://gluon.io
06-25 23:53:43.494: W/System.err(31439): at com.gluonhq.impl.cloudlink.client.CloudLinkConfiguration.validateCredentials(CloudLinkConfiguration.java:85)
06-25 23:53:43.494: W/System.err(31439): at com.gluonhq.cloudlink.client.push.PushClient.enable(PushClient.java:70)
而且,当我从Firebase控制台发送测试通知时,设备上什么也没收到。
Gluon推送通知服务支持Firebase推送通知还是仅支持其自己的CloudLink服务?
如果它可以与Firebase一起使用,则需要更改哪些内容,以使其通过Firebase服务接收通知?