本文介绍了在IBM Worklight推送通知中使用轮询时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Android设备进行WL 6.0推送通知。推送通知工作正常。我也试图使用Polling。根据信息中心的文档,

I was trying out WL 6.0 Push notification with Android device. Push notifications is working fine. I was also trying to use Polling. As per the docs from Info center,

对于轮询,我们需要调用另一个过程,并且在我们从该过程方法获得响应的某些时间间隔后,推送完成。如果我错了,请纠正我。

for polling we need to invoke another procedure and after certain intervals when we get response from that procedure method push is done. Please correct me if I'm wrong.

因此,我已经宣布了一个名为 getNotificationsFromBackend 的新程序并调用了它。

So, as per this I have declared a new procedure named getNotificationsFromBackend and invoked that.

喜欢这个

WL.Server.createEventSource({
    name: 'PushEventSource',
    onDeviceSubscribe: 'deviceSubscribeFunc',
    onDeviceUnsubscribe: 'deviceUnsubscribeFunc',
    securityTest:'PushApplication-strong-mobile-securityTest',
    poll: {
        interval : 3,
        onPoll: getNotificationsFromBackend
    }
});

function getNotificationsFromBackend() {
    WL.Logger.debug("hi");

}

现在,我遇到的问题是我遇到的问题订阅(来自示例应用),控制台说无法找到适配器。不知道什么是错的,请帮我解决这个问题。

Now, the problem I'm facing is when I hit Subscribe (from the sample app), console says it is unable to find the Adapter. Don't know whats going wrong, please help me on this.

我在控制台得到这个,

[ERROR   ] FWLSE0020E: Ajax request exception: Adapter 'PushAdapter' does not exist [project PushNotificationsProject]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project PushNotificationsProject]Adapter 'PushAdapter' does not exist, User Identity {wl_authenticityRealm=null, wl_remoteDisableRealm=(name:null, loginModule:NullLoginModule), wl_antiXSRFRealm=(name:rcs7pje8os4fk6p59en152iqrq, loginModule:WLAntiXSRFLoginModule), PushAppRealm=(name:ss, loginModule:PushAppLoginModule), wl_deviceAutoProvisioningRealm=null, wl_deviceNoProvisioningRealm=(name:c343dd38-7688-35e2-8dde-2c6acaae1930, loginModule:WLDeviceNoProvisioningLoginModule), myserver=(name:ss, loginModule:PushAppLoginModule), wl_anonymousUserRealm=null}. [project PushNotificationsProject]
                                                                                                               com.worklight.common.log.filters.ErrorFilter


推荐答案

问题的原因是您的适配器未成功部署。我尝试了这个代码,它工作正常。按指定的时间间隔获取通知。

The reason for the problem is that your adapter was not successfully deployed. I tried this code and it works fine. Get notifications at the specified interval.

WL.Server.createEventSource({

    name: 'PushEventSource',
    onDeviceSubscribe: 'deviceSubscribeFunc',
    onDeviceUnsubscribe: 'deviceUnsubscribeFunc',
    securityTest:'PushApplication-strong-mobile-securityTest',
    poll: {
        interval : 3,
        onPoll: 'getNotificationsFromBackend'
    }
});


function getNotificationsFromBackend() {

    WL.Logger.debug("hi");
    submitNotification("User1","This is Poll Notification");
}

您的适配器代码的问题似乎缺少函数名称的引号 onPoll 参数。

The problem with your adapter code seems to be missing quotes for the function name for onPoll parameter.

这篇关于在IBM Worklight推送通知中使用轮询时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:04