Ibm mobilefirst MobileFirst和Ionic推送通知回调

Ibm mobilefirst MobileFirst和Ionic推送通知回调,ibm-mobilefirst,Ibm Mobilefirst,我有一个Ionic项目,我添加了一个推送通知回调处理程序,正如官方文档中所解释的那样(我的期望是在应用程序内部出现一些警报,通知到达时),但它从未被调用 WL.Client.Push.registerEventSourceCallback( "myPush", "PushAdapter", "PushEventSource", pushNotificationReceived); 这里的问题是我

我有一个Ionic项目,我添加了一个推送通知回调处理程序,正如官方文档中所解释的那样(我的期望是在应用程序内部出现一些警报,通知到达时),但它从未被调用

  WL.Client.Push.registerEventSourceCallback(
            "myPush",
            "PushAdapter",
            "PushEventSource",
            pushNotificationReceived);
这里的问题是我必须将pushNotificationReceived函数放置在何处才能调用?我尝试在index.js和控制器内部作为函数,但没有成功。
感谢帮助

您是否查看了推送通知的示例应用程序?。 该示例演示了推送通知API的实现


请参阅提供的main.js文件:

在“成功连接到mobile first server”之后,您必须在app.js文件中的爱奥尼亚中包含回调函数


回调应该在注册回调的js中定义。您是否在设备中接收推送通知?是不是通知没有显示在回调中?这真的与您现有的问题不同吗?是的,另一个问题是关于最近的列表清理,这一个是当应用程序打开并处于前台时。嗨,Idan,答案是肯定的,并且示例按预期工作,但我无法用Ionic framework复制它。不调用回调函数。
     WLAuthorizationManager.obtainAccessToken().then(
            function (response) {
              //alert("successfully obtained a token from the server");
                MFPPush.initialize (
                   function(successResponse) {
                       //alert("Successfully intialized");
                        MFPPush.registerNotificationsCallback(notificationReceived);
                   },
                   function(failureResponse) {
                        console.log("Failed to initialize");
                   }
                );
                MFPPush.isPushSupported (
                    function(successResponse) {
                       //alert("Push Supported: " + successResponse);
                    },
                    function(failureResponse) {
                        console.log("Failed to get push support status");
                    }
                );
                MFPPush.registerDevice(
                    function(successResponse) {
                        //alert("Successfully registered");
                    },
                    function(failureResponse) {
                        console.log("Failed to register");
                    }
                );
                function notificationReceived(message) {
                    alert(JSON.stringify(message.alert));
                }
         }, 
         function(response) {
            //alert("res"+JSON.stringify(response));
            console.log("Unable to obtain a token from the server: " +            JSON.stringify(response));
            if(JSON.stringify(response.status) ==  403){
                 console.log("The Application is disabled on this Device");
                 ionic.Platform.exitApp();
            }
        }
     );