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

iOS asks for push notification confirmation on app start #201

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

iOS asks for push notification confirmation on app start #201

benmcmaster opened this issue Oct 4, 2015 · 22 comments

Comments

@benmcmaster
Copy link

The push notification confirmation dialog shows when the app starts. Not when calling init/registration of the push notification.

I would love to control when the permission dialog is shown. Is there any way to do that?

Is the dialog being shown because of local notifications and remote notifications permissions are bundled? See this link:
http://www.tagwith.com/question_791213_ios-8-cordova-app-requests-push-notification-permissions-immediately-on-first/

This is an issue in the old PushPlugin:
phonegap-build/PushPlugin#378

@macdonst
Copy link
Member

macdonst commented Oct 5, 2015

@benmcmaster this was reported by another user awhile ago but I never could reproduce it and went away for him. Can you give me some more detail on the reproduction scenario? If you are not calling PushNotifcation.init() on "deviceready" you shouldn't see the request for push permission dialog.

@benmcmaster
Copy link
Author

Hey @macdonst ! Yeah, I removed the call to PushNotifcation.init() completely from my code, and I am still getting the permission dialog on app startup. It's like something else is running when the plugin code is included...

I am also using Phonegap Build.

@benmcmaster
Copy link
Author

@macdonst is there anything else I can give you to help recreate the issue?

@macdonst
Copy link
Member

@benmcmaster Nah, I just did a factory reset on one of my devices and I'll be trying out exactly this issue on a fresh device tonight.

@macdonst
Copy link
Member

@benmcmaster I can't reproduce this issue. I have a project setup so that Push.init() is not called until I click on a button. Take a look at this video:

https://dl.dropboxusercontent.com/u/887989/pushplugin/PushInit.mov

I star the app, no push permission dialog. Then you can see the flash on the button where I tap it. Immediately the push permission dialog shows up then the app receives a registration ID.

If there is anyway you can give me a reproduction scenario for this one I'd appreciate it.

@benmcmaster
Copy link
Author

@macdonst Hmm. Did you build that with Phonegap Build?
Is that code in a github repo? I could grab it, and build it on my end...

@macdonst
Copy link
Member

@benmcmaster No, I didn't build it with PGB.

Here is a link to the index.js I used. It is the same as my sample in the repo but it changes where Push.init() is called.

https://dl.dropboxusercontent.com/u/887989/pushplugin/index.js

the only other thing you'll need to do is create an element with and id of ack to be able to trigger the init method.

@benmcmaster
Copy link
Author

@macdonst I just took the example included in this repo, and your new index.js. I built your code with PGB. I am still getting the permission dialog on app start. I even commented out all of the registration code in index.js just in case. I still get the permission dialog on app start. Somehow the constructor of the PushNotification class is getting called on app startup without calling init().

Using phonegap version cli-5.2.0

@benmcmaster
Copy link
Author

@macdonst There is a line of code at the top the plugin push.js code inside of the .ipa that PGB compiles... looks like PGB wrapped the plugin code with:

cordova.define("phonegap-plugin-push.PushNotification", function(require, exports, module) {

// normal plugin code 

});

I have never built a plugin before, and I have limited iOS experience. I wonder if that code is somehow calling the constructor...

@benmcmaster
Copy link
Author

@macdonst One more update: Looks like it's not a JS problem. I pulled the init code out of the constructor in push.js and created an PushNotification.prototype.init function and added some console logs just to make sure. I pushed my version up to my npm account and pointed PGB to grab the plugin from there.

I am still getting the permission confirmation dialog without any of the init JS code being called at all. It must be something on the iOS side of things... What could PGB be doing different?

@martinfilliau
Copy link

We still have the same issue (as described in #49)...

@macdonst
Copy link
Member

@benmcmaster No, don't worry about that module line. What version of iOS are you using?

@martinfilliau are you using PGB? What version of iOS?

@benmcmaster
Copy link
Author

@macdonst I have noticed this bug since iOS 8 came out. Currently I am using iOS 9.0.1.

@macdonst
Copy link
Member

@benmcmaster @martinfilliau can anyone put together a small project that demonstrates it with a repo scenario? I can't seem to reproduce the problem. I believe it is a problem I just can't figure out what variable to tweak in order to reproduce it. Maybe it is another plugin that you guys are using that confuses things. If I can get some more detail I'd love to get this fixed.

@benmcmaster
Copy link
Author

@macdonst I literally just took the example project from this repo and built it with PGB. There were no other plugins in the project... I will try and see if there is anything else I can isolate...

@DamiJegede
Copy link

Hi @macdonst — I think it's from Phonegap Build. I'm using the build service as well. Could you kindly try to compile your repo with Phonegap build at https://build.phonegap.com/

@hermandroid
Copy link

Hi Everyone, I can confirm that this is only an issue when building a project by means of PhonegapBuild.

When I create a project from the CLI and open up the resulting iOS project in XCode then run it to device (or Archive and distribute from there) the confirmation dialog only appears if and when the "PushNotification.init" call takes place.

However as mentioned by @benmcmaster when I upload and build through PGB the confirmation dialog appears as soon as the app starts up the first time. Even if I remove all of the plugin referencing / calling code completely but just leave the plugin element in the config.xml file.

@martinfilliau
Copy link

We also use PGB and have noticed the problem on iOS 8 and 9 as well.

@benmcmaster
Copy link
Author

It's now working with release 1.4.2 built on PGB. I don't get the confirmation message on app startup on iOS 9. Can anyone else confirm this? Anyone have an iOS 8 test device?

@acurrieclark
Copy link

For anyone stumbling upon this thread searching for this very same issue, in later version of iOS (8 onwards I believe) it is also necessary to get permission to set badges. So if you make an attempt to set a badge using a different plugin before calling push.init() then the permission dialog will be shown.

@macdonst
Copy link
Member

Closing, inactivity. Also, we are up to iOS 11.3 now so supporting 8.x is not longer required.

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

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

No branches or pull requests

6 participants