Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

Windows unregisterDevice returns null #220

Closed TimKolberger closed 7 years ago

TimKolberger commented 7 years ago

Environment: Cordova 4.2 with the latest pushwoosh-phonegap-plugin on the windows platform. It is possible to register the device, and to receive push notifications (see #219 ) But it is not possible to unregister the device:

var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");`
pushNotification.unregisterDevice(
            function (status) {
                console.log('success', status);
            },
            function (status) {
                console.log('failure', status); // -> status = null
            }
);
wfhm commented 7 years ago

Hi,

it is not possible to unregister the device

Do you mean that 'success' callback is never returned?

console.log('failure', status); // -> status = null

pushNotification.unregisterDevice will never return a 'failure', it always returns 'success' in any case.

TimKolberger commented 7 years ago

The PluginProxy function unregisterDevice always returns an error, because this.service.unsubscribeFromPushes() needs two parameters (throws exception).

pushwoosh-phonegap-plugin/src/windows/PushwooshPluginProxy.js:44

unregisterDevice: function(success, fail) {
        this.service.unsubscribeFromPushes();
        success();
    },

I edited the PluginProxy to use the success and failure handler:

EDITED: PushwooshPluginProxy.js:44

unregisterDevice: function(success, fail) {
        this.service.unsubscribeFromPushes(success, fail);
    },

In either way, the unregister function does not have any effect.

TimKolberger commented 7 years ago

any news on this issue?

wfhm commented 7 years ago

Hi,

Callbacks are working fine with a native plugin and devices are being unregistered. With WinJS these callbacks are not being called (due to WinJS mechanics, and it is out of our control).

We have tested it and unregisterDevice is indeed unregistering a device as expected. The failure callback issue actually known for some time, so unregisterDevice for Cordova Windows plugin always calls success() and at the moment it is the only possible option.