简体   繁体   English

IBM Worklight 6.0-在iOS模拟器中进行预览时,如何避免推送通知错误?

[英]IBM Worklight 6.0 - How to avoid push notifications error when previewing in the iOS Simulator?

I am using IBM Worklight 6.0.0 and testing on iOS 7 Simulator. 我正在使用IBM Worklight 6.0.0并在iOS 7 Simulator上进行测试。

I have the following JavaScript error. 我遇到以下JavaScript错误。 It appears everytime I login. 每次我登录时都会出现。

Error while trying to retrieve device token from the mobile operating system.
  (anonymous function)           cordova.js:5312
  __log                        worklight.js:1292
  (anonymous function)         worklight.js:1377
  __updateTokenCallbackError    wlgap.ios.js:403

On the client side, my code is: 在客户端,我的代码是:

if (WL.Client.Push){

    WL.Client.Push.onReadyToSubscribe = function(){
        WL.Logger.debug("onReadyToSubscribe");

        if (isPushSubscribed() == false) {
            doSubscribe();
        }
    };  
}
if (WL.Client.Push){
        WL.Client.Push.registerEventSourceCallback(
                "myPush", 
                "PushAdapter", 
                "PushEventSource", 
                pushNotificationReceived);
}

How can I avoid this error? 如何避免此错误?

Use Cordova's device.name API method. 使用Cordova的device.name API方法。 You can also use WL.Client.getEnvironment to do the same, but for when previewing in the Worklight Console. 您也可以使用WL.Client.getEnvironment进行相同的操作,但在Worklight Console中进行预览时除外

If you get "iPhone Simulator" (or "Preview" in the case Worklight Console), don't enter into those code blocks... do something else instead. 如果您收到“ iPhone模拟器”(或在Worklight Console中为“预览”),请不要输入这些代码块...而是执行其他操作。 Otherwise, continue into them. 否则,继续进行下去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM