Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS registerDevice() only works once #230

Closed
beck24 opened this issue Dec 12, 2016 · 2 comments
Closed

iOS registerDevice() only works once #230

beck24 opened this issue Dec 12, 2016 · 2 comments

Comments

@beck24
Copy link

beck24 commented Dec 12, 2016

[edit] - original plugin version 6.2.2, upgraded to 6.4.0 and still experiencing the same issue

I have a simple interface for toggling notifications on/off. When off it calls unRegisterDevice() and when on it calls registerDevice()

At some point recently the registerDevice() function stopped working for repeated calls. When the app first loads, if the saved state (or default state) is to allow notifications, then the registerDevice() function works the first time. It registers the device properly, and my success callback is triggered. I also have an error callback in place, presumably that is called in case of an error.

Now when notifications are turned off unRegisterDevice() is called, and the callback is triggered.

If you want to turn notifications on, registerDevice() is called again but neither the success nor the error callbacks are triggered and the device is not registered to receive notifications.

For reference here is the function that toggles notifications on (with a bunch of debugging code in it)

// push Notifications
$scope.pushNotifOn = function() {
    console.log('push notifications clicked on');
    if (window.hasOwnProperty('plugins') && window.plugins.hasOwnProperty('pushNotification')) {
        //register for pushes
        console.log('plugin exists, calling registerDevice');
        console.log(window.plugins.pushNotification);
        window.plugins.pushNotification.registerDevice(
           function(status) { console.log('registerDevice success');
                window.localStorage['pushNotif'] = true;
                var pushToken = status;
                $rootScope.deviceToken = pushToken;
                console.log('notifications on');
                console.log(window.device.uuid);
                console.log(pushToken.pushToken);
                
                if ($scope.user.hasOwnProperty('guid')) {
                    UsersService.notificationsOn({
                        device: window.device.uuid,
                        token: pushToken.pushToken
                    });
                }
            },
            function(status) {
                console.log('registerDevice Error');
                console.log('failed to register');
                console.log(status);
            }
        );
        console.log('end of push notifon');
    }
};

When the device loads the console log shows as it should, with:

console.log('notifications on');
console.log(window.device.uuid);
console.log(pushToken.pushToken);

properly being logged.

When notifications are toggled off, and then on the console log looks like this:
screen shot 2016-12-11 at 6 23 35 pm

As you can see my function is called, but there is nothing logged for the registerDevice() callbacks.
I logged the window.plugins.pushNotification object just to make sure it was what I expect it to be and it appears to be the pushwoosh plugin and lists the registerDevice prototype function. I'm at a loss to explain this but I really need a solution.

@wfhm
Copy link
Member

wfhm commented Dec 15, 2016

Hi,

This seems to be out of our control. Please refer to Pushwoosh/pushwoosh-unity#18 (comment) for additional details and a possible workaround.

@shaders
Copy link
Contributor

shaders commented Dec 19, 2016

Hi,

As mentioned above unregisterForRemoteNotifications is broken on iOS10. To implement opt-in/out strategy simply create a tag "optin", set this tag when user opts-in for push notifications (or set it to null (unset) for opt-out) and then send push using this the filter with tag.

I hope this helps.

@shaders shaders closed this as completed Dec 19, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants