Firebase plugin, push notifications and including this plugin


The docs is saying:

Make sure you [require the plugin in app.ts / main.ts / **main.aot.ts before* application.start()** , and do init() after the app has started (not in app.ts - not even in a timeout; move it out of app.ts entirely!).

But, i have a login page that ask for login and password, and as result, when im requiring this plugin in app.js prompt message is shown asking for permissions.
I wanted to ask user for .this after login, and is this possible ?

Thank you.


Simply importing the plugin will not ask for permission.You may call init after login.


I can confirm that if i remove require firebase, app is not asking for permissions.
And if this is present in app.js permission will be shown…
var firebase = require(“nativescript-plugin-firebase”);
it’s pretty bad, but i’m sure that require is doing this.


@Eddy , please, can you confirm ?
Right now plugin works very well, but this permissions notification on login page is pretty bad from UI perspective.
Thank you.


Can you share a repo? That should not happen unless you also init with a notification handler.


I will prepare the code asap.
but first i’ll uninstall push-notifications-plugin as i don’t need this now, as i’m using firebase.
Does this make sense?
Kind regards,


I didn’t provide example code, but created empty generic N project.
Only thing that i’ve done, was:

1.tns plugin add nativescript-plugin-firebase
2. added require to app.js
3. Created GoogleServeice-info.plist under app_resources/IOS

The result is:

below app.js :

In NativeScript, the app.js file is the entry point to your application.
You can use this file to perform app-level initialization, but the primary
purpose of the file is to pass control to the app’s first module.
var firebase = require("nativescript-plugin-firebase");

var application = require("application");{ moduleName: "app-root" });

Do not place any code after the application has been started as it will not
be executed on iOS.

Thats all, simple path to recreate this “issue”…
Thanks for checking this.

IOS: 11.4
N: 4.1
“nativescript-plugin-firebase”: “^6.4.1”,


What’s more, when starting app, first thing is :
CONSOLE LOG file:///app/tns_modules/nativescript-plugin-firebase/firebase.js:2394:20: >> fcmToken received: fo5LeBiTpn0:APA91bG-e8exZqtFyPYd-M02NhXteR4_rQrzqd9wFosUO7_WhibLWo5oViZhgbn0W8Trg0B6HOp8w_rbKs1D_O7FNG-XM2rXAwBTuP9sZcEqqwjhcCm4EncK1MVdvkZ5HrrrpFaCB_0f8fqsQZRzPRtUj5CAg

Just after this console.log, permission appears.


This is a strange issue and never happens at least on my end with same code. As Eddy requested, share a repo - complete example project where we can reproduce the issue.


I will do this, thanks.