尝试了推送通知示例: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控制台发送测试通知时,设备上没有收到任何内容 .
Does Gluon push notification service support Firebase push notifications or only its own CloudLink service?
如果它适用于Firebase,来自pushnotes示例的 what needs to be changed ,以使其通过Firebase服务接收通知?