IBM Worklight - 无法使用现有别名注册事件源回调。别名已用于事件源 [英] IBM Worklight - Cannot register to event source callback with an existing alias. The alias is already in use for event source

查看:126
本文介绍了IBM Worklight - 无法使用现有别名注册事件源回调。别名已用于事件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IBM Worklight 6.0.0并在iOS 7设备上测试。

I am using IBM Worklight 6.0.0 and testing on iOS 7 device.

我有以下js错误:

Cannot register to event source callback with an existing alias: 'myPush'. The alias is already in use for event source 'PushEventSource'.

在设备上登录时,请注销,然后重新登录。 (错误第二次出现)

On device, when I login, logout then login again. (error appear the second time)

在客户端,我的代码是:

On the client side, my code is:

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

我的代码有问题吗?

是因为我应该调用WL.Client.Push.registerEventSourceCallback只有一次?

Is it because I should call "WL.Client.Push.registerEventSourceCallback" only once?

任何其他解决方案吗?

推荐答案

错误消息显示您不能多次注册别名。错误不是有害的,因为无论错误消息你仍然可以接收推送通知(你可能想测试这是肯定的)。

You are not allowed to register an alias more than once as the error message shows. The error isn't that harmful, since regardless of the error message you can still receive push notifications (you may want to test this to be sure).

如果你想为避免错误消息,您有两个选项:

If you want to avoid the error message you have two options:


  1. 确保调用WL.Client.Push.registerEventSourceCallback
    每个应用程序会话只调用一次,而不管用户是否已注销

  1. Ensure that the call to WL.Client.Push.registerEventSourceCallback is called only once per app session, regardless of whether or not the user has logged out.

拨打WL.Client。当用户注销
时,取消订阅,清除别名到事件源的绑定。

Make a call to WL.Client.Push.unsubscribe when the user logs out to clear the binding from the alias to the event source.

我建议使用选项1.推送通知绑定到设备,而不是用户。除非您计划更改不同用户的事件源别名,否则不需要取消订阅。

I'd suggest going with option 1. Push notification is tied to the device, not the user. Unless you plan on changing the event source alias for different users, there is no point in unsubscribing.

这篇关于IBM Worklight - 无法使用现有别名注册事件源回调。别名已用于事件源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆