IBM Worklight – 无法使用现有别名注册到事件源callback。 别名已经被用于事件源

我正在使用IBM Worklight 6.0.0并在iOS 7设备上进行testing。

我有以下js错误:

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

在设备上,当我login,注销然后再次login。 (第二次出现错误)

在客户端,我的代码是:

 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”?

任何其他解决scheme

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

如果你想避免错误消息,你有两个select:

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

  2. 在用户注销时调用WL.Client.Push.unsubscribe来清除从别名到事件源的绑定。

我build议去select1.推送通知绑定到设备,而不是用户。 除非您计划更改不同用户的事件源别名,否则取消订阅没有任何意义。