【问题标题】:Implementation of push notification using oracle maf使用 oracle maf 实现推送通知
【发布时间】:2016-05-26 13:24:50
【问题描述】:

我能够使用设备令牌进行注册。但我没有收到来自服务器的消息。我已经在 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);
}

}

【问题讨论】:

  • 你能告诉我你从哪里调用这些 onOpen , onError 方法吗??
  • 来自 LifeCycleListenerImpl.java public void start() { EventSource evtSource = EventSourceFactory.getEventSource(EventSourceFactory.NATIVE_PUSH_NOTIFICATION_REMOTE_EVENT_SOURCE_NAME); evtSource.addListener(new NativePushNotificationListener()); }
  • 以上代码sn-p来自NativePushNotificationListener?
  • 是的......但是当我从服务器发送消息时,我收到一个警告......
  • 你收到了什么信息?请提供完整信息

标签: oracle-maf


【解决方案1】:

我认为this article 会帮助你。我能够为 GCM 完成它们,但还不能为 APN 完成。

如需注册 Google Cloud Messaging,请转至 this link,然后点击“获取配置”按钮。

在服务器应用程序中,正确设置您的设备令牌和发件人 ID。使用这些发送消息。

【讨论】:

    【解决方案2】:

    既然您从服务器获得了deviceId,那么我认为问题不在于代码。您是否在maf-application.xml 中启用了PushPlugin

    【讨论】:

    • 能否告诉我 onMessage() 是否调用?
    • 我不确定...我认为它没有被调用。
    • 然后使用 System.out.prinln() 试试,这样你就可以检查该方法是否被调用
    猜你喜欢
    • 1970-01-01
    • 2018-11-22
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多