Nativescript-plugin-firebase: Push Notifications with Vue

Created on 20 Oct 2018  路  5Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

I have the notifications being received properly from Firebase when the app is open, but nothing when the app is in the background. In my main.js I have

firebase.init()
  .then(instance => console.log("firebase.init done"))
  .catch(error => console.log(`firebase.init error: ${error}`));

before new Vue...

The section What is iOS doesn't receive notifications in the bg says to require it and take it out of app.ts. How does this correlate to main.js? I'm also still including it like import * as firebase from "nativescript-plugin-firebase".

The notification is being created in a top-level component (to avoid the permission until after logged in) like so:

firebase.addOnMessageReceivedCallback(
      function(message) {
        alert({
            title: message.title,
            message: message.body,
            okButtonText: "OK"
          })
          .then(() => {
            console.log("Alert dialog closed.");
          });
      }
    );

I'm also not sure if this is the best to show a background notification , but I'm not finding a lot of information on this part right now.

Messaging bug iOS

Most helpful comment

Thanks again, Eddy. Just wanted to confirm here that it's working properly on iOS now. Woo!

All 5 comments

Share a repo please and reopen. This kind of issues is impossible to help with unless there鈥檚 a project to inspect.

UPDATE: the repo was shared and I'm looking into it.

OK, this turned out to be a very tough 馃崻to crack. The problem seemed to be the timing of a bundled NativeScript-Vue app is a bit different from core/Angular, which meant the most recent APNs token wasn't sent to Firebase.

The solution is having the plugin send the APNs token to Firebase so it's correctly associated with the FCM token the developer receives in onPushTokenReceivedCallback. This actually may also fix issues with NativeScript-Angular apps struggling to require the plugin on-time.

Available with 7.3.0, will publish soon.

Thanks again, Eddy. Just wanted to confirm here that it's working properly on iOS now. Woo!

Excellent!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vchimev picture vchimev  路  3Comments

jlooper picture jlooper  路  3Comments

Aceman18 picture Aceman18  路  3Comments

bunower picture bunower  路  3Comments

andrewexton373 picture andrewexton373  路  4Comments