我可以使用device token.but注册,我没有收到来自服务器的消息。我已经向GCM注册了我的项目,并获得了项目Id和服务器密钥。
在此处输入代码
public void onMessage(Event event) {
String msg;
msg = event.getPayload();
System.out.println("#### Message from the Server :" + msg);
String one="";
AdfmfContainerUtilities.invokeContainerJavaScriptFunction(AdfmfJavaUtilities.getFeatureId(), "usercheck", new Object[]{msg});
// Parse the payload of the push notification
HashMap payload = null;
String pushMsg = "No message received";
try
{
payload = (HashMap)JSONBeanSerializationHelper.fromJSON(HashMap.class, msg);
pushMsg = (String)payload.get("alert");
}
catch(Exception e) {
e.printStackTrace();
}
// Write the push message to app scope to display to the user
AdfmfJavaUtilities.setELValue("#{applicationScope.pushMessage}", pushMsg);
}
public void onError(AdfException adfException) {
System.out.println("#### Error: " + adfException.toString());
// Write the error into app scope
AdfmfJavaUtilities.setELValue("#{applicationScope.errorMessage}", adfException.toString());
}
public void onOpen(String token) {
System.out.println("#### Registration token:" + token);
// Clear error in app scope
AdfmfJavaUtilities.setELValue("#{applicationScope.errorMessage}", null);
// Write the token into app scope
AdfmfJavaUtilities.setELValue("#{applicationScope.deviceToken}", token);
}}
发布于 2016-03-10 21:17:47
我想this article会帮你的。我可以为GCM完成它们,但还不能为APN完成。
要注册Google Cloud Messaging,请转到this link,然后单击"Get configuration“按钮。
在服务器应用程序中,正确设置设备令牌和发送者id。消息是使用它们发送的。
发布于 2016-04-06 15:34:30
既然你从服务器得到了deviceId,那么我认为问题不是代码的问题。您是否在maf-application.xml中启用了PushPlugin?
https://stackoverflow.com/questions/35766405
复制相似问题