Issue while using Polling in IBM Worklight Push Notification

喜欢而已 提交于 2019-12-01 11:32:00

问题


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.

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

like this

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.

I am getting this in console,

[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

回答1:


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");
}

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



来源:https://stackoverflow.com/questions/18680789/issue-while-using-polling-in-ibm-worklight-push-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!