0

デバイス トークンを使用して登録できますが、サーバーからメッセージを受信しませんでした。プロジェクトを 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);
}

}

4

2 に答える 2