Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Clean way to detect "Don't Allow" of push notification permissions on iOS? #202

Closed
benmcmaster opened this issue Oct 4, 2015 · 18 comments
Closed

Comments

@benmcmaster
Copy link

Is there a good way to detect if the user denied push notification permissions? (iOS)

In the old PushPlugin I was using a set timeout. Basically if the registration function doesn't come back I assume there was an error. It's hacky. Do we still have to do that? I wish there was a better way.

Here is an example of using a setTimeout in the old PushPlugin:
http://stackoverflow.com/questions/25844812/cordova-how-to-detect-if-push-notifications-are-disabled-on-the-device

@macdonst
Copy link
Member

macdonst commented Oct 5, 2015

@benmcmaster no, there really isn't. The way iOS works is you can check to see if the application has been registered for push notifications or not but there is no way to tell if they haven't yet approved the app for push or if they have denied permission for push. I'll have to have more of a think on it.

@benmcmaster
Copy link
Author

@macdonst yeah, I figured as much. Doing the setTimeout is working ok for me. If registration event never fires I can assume push notifications are not working for that user.

@hirbod
Copy link

hirbod commented Oct 19, 2015

@macdonst here you find many working concepts how to realize this.
I think it should be possible to provide a .hasPushPermission() or something like that.

http://stackoverflow.com/questions/1535403/determine-on-iphone-if-user-has-enabled-push-notifications

@macdonst macdonst added this to the Release 1.5.0 milestone Oct 28, 2015
@tyronedougherty
Copy link

+1, would be a great addition to the plugin. 😄

@eladmoshe
Copy link
Contributor

+1

1 similar comment
@zwacky
Copy link
Contributor

zwacky commented Nov 3, 2015

+1

@zwacky
Copy link
Contributor

zwacky commented Nov 3, 2015

i forked this feature here, only iOS at the moment. it should have < ios8 and >= ios8 support.

https://github.com/zwacky/phonegap-plugin-push

usage:

window.PushNotification.hasPermission((isEnabled) => {
    if (isEnabled) {
        var push = window.PushNotification.init({
            ...
        });
    }
});

@macdonst
Copy link
Member

macdonst commented Nov 3, 2015

@zwacky Pull requests are more than welcome.

@zwacky
Copy link
Contributor

zwacky commented Nov 3, 2015

will do when i got android ready

@macdonst
Copy link
Member

macdonst commented Nov 3, 2015

👍

might be a bit slow to respond as I'm off to EU in a few hours on a business trip.

@bau720123
Copy link

hi all
for now it is already have a plugin can do this thing and really work to detect the push notification enable or disable
https://www.npmjs.com/package/com.nrswolf.cordova.push-notifications-status

@zwacky
Copy link
Contributor

zwacky commented Nov 4, 2015

true, @bau720123. although it only covers iOS.

pull request: #305

@bau720123
Copy link

thanks @zwacky
maybe wait @macdonst to merge yours

@stinju
Copy link

stinju commented Nov 7, 2015

@zwacky et al, would it be useful to return sound/alert/badge booleans as well for iOS? It is platform-specific, but probably useful in many developer contexts.

@fabiocaccamo
Copy link

+1

@macdonst
Copy link
Member

Handled by PR #305

@macdonst macdonst removed the retest label Dec 18, 2015
@macdonst
Copy link
Member

Merged into master.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

9 participants