Nativescript plugin firebase - Delay permission for app notifications


#1

Hi
In my nativescript angular app I find that the notification permission is asked for immediately on firebase init in IOS. (not so in android).
This even though i am not setting up the notification handlers at the time I am initialising firebase.

You can see this issue using this repository . I am using Nativescript 4.2 and Nativescript-plugin-firebase version 6.5.0

Can someone suggest a way by which I can delay the the pop-up for the notifications permission on IOS.


#2

firebase init alone will not ask for notification permission until you set any notification callback there.


#3

Thanks for your response @manojdcoder. I have not setup any notification callback. You can see this from the github repo that I have created. I am not getting the pop-up on android, but on IOS it shows up as soon as the app starts. Could you take a look please.


#4

Android doesn’t need any permission to initialize push, but iOS does so you can’t compare them.

I do use the same plugin, initialize firebase at ngOnInit of the app component but I don’t get any permission dialog until I invoke the get token method. I will try to take a look at the repo later today and let you know if I find anything.


#5

Thanks @manojdcoder!


#6

Looks like this was a change made in recent versions, all the hacks given earlier to prevent this dialog no longer valid.

So I think @Eddy will be the right person to answer why this change was necessary.


#7

Thanks @manojdcoder. @Eddy - please take a look when you get a chance. Thanks


#8

@anuragd7 Try commenting out this line in node_modules/nativescript-plugin-firebase (and clean the platforms/ios folder, and let me know how it goes: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/5c5b1af7c0cfc9f3ce87e401f427e3972c75ddf1/src/firebase.ios.ts#L556


#9

Thank you @Eddy It should work. But may I ask you why the plugin forces it, at least it used to have hacks earlier. Do you have any plan to make this possible without editing the plugin in future releases?


#10

Because people require/import the plugin in different ways in different files in different frameworks and I get a few emails and issues every single week with folks complaining about push issues on iOS. And every single time I can fix their app by doing what’s documented in the plugin readme.

This change seemed to make it work better regardless the usage.

I may go back to something like this ‘hack’, but we’re also doing an extensive rework on the notifications implementation so let’s first see how that pans out. Keep an eye on the plugin changelog, but for now I’d be curious to learn if this little change helps.


#11

Thank you for the info, a hack to control the behaviour will be great.
Firebase plugin has almost become a must for all apps, thank you again for all the efforts and great plugins.


#12

Hi @Eddy. Just tried it out. Can confirm that I don’t get the notifications alert after commenting out this line. Thanks for the help.


#13

Today I’ve changed the implementation of this consent popup to allow for delaying it again. Will be part of plugin version 6.7.0 which will be released next week. Details @ https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/885.