Push Notifications on Meteor in 2019

Hey guys,

I’m looking for a solution to handle push notifications in my Meteor apps. The situation is:
I have an Admin App (Web) and a User App (Android and iOS). I want to be able to send push notifications from the Admin App to the User App. I don’t need segregation - all push notifications will be sent to all users.

I checked out raix:push, but it’s maintenance status is dubious (relies on lots of outdated plugins/packages) and honestly speaking it feels like too much hacking around (resulting in hundreds of open issues and bugs).

Is there any solution you would recommend for my use case?
Thanks!

1 Like

Hey,

Thanks for the reply! A few questions:

  • I am using Blaze. Are there any restrictions?

  • As mentioned above, I have 2 apps - one running in the web (and sending push notifications) and the other running on mobile (receiving them). They are hosted with different domains. Is this a limitation?

Thanks!

None of the various push notification modules/packages provide any UI code, so you can use whatever view layer you want.

The web app cannot send push messages directly to the mobile app, you need your own server in between. Your server sends the message via Google Cloud Messaging using your private API key (which you do not want to expose to the client).

Having the sender and receiver on different domains doesn’t matter at all.

1 Like

Thanks for the explanation.
One question is still in my mind, though…

My web app and mobile app are deployed separately (each having their own server).
So my push notifications will be sent from the web app’s server to the mobile app’s client directly (through Cloud Messaging)?

I’ve just re-read your first post, and I overlooked that you want all messages to be sent to all users.

That makes it easier, and in that case you CAN have your web app and mobile app connected to different servers because your web app’s server doesn’t need to know the GCM tokens of each recipient device.

In that case your mobile apps can subscribe to a ‘channel’. E.g., as soon as the app loads they might subscribe to the ‘allUsers’ channel. When a user logs in they might subscribe to the ‘loggedInUsers’ channel. You might want a channel just for Android users and another for iOS users. Etc, etc. Each device can be subscribed to multiple channels at once.

Subscribing to a channel is a transaction between the mobile client and GCM directly - your server isn’t involved.

Then your web app server can just connect to GCM using your private API key, and send the message to a specific channel. All mobile apps subscribed to that channel will receive the message via their connection to Google’s server.

3 Likes

Hi @wildhart,

I am looking through the FCM SDK: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/#androidnotification
channel_id seems to be specific to Android O. I think topic fits the purpose as described above.
What do you think? Just looking out for some brain food as I feel I don’t have a viable (enough) implementation of topics in our package. I missed the user subscription and the necessary hooks to subscribe to one or many, unsubscribe from one or many, list topics subscribed to etc. E.g.: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushsubscribetopic-successhandler-errorhandler

1 Like

Yeah, sorry, I meant topics, not channels! I don’t actually use them myself and it’s been a while since I looked at that code.

I currently use phonegap-plugin-push on the client (although it’s suffering a bug which prevents the .on('notification') callback from being called on Android when the app is in the background), and firebase-admin on the server.

You must be ‘suffering’ with this: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads. This is implemented in activitree:push. Entire Android content goes as ‘data’.

Thanks for the explanation, guys! So just to confirm:

Can I use activitree:push to achieve what I need?

If you feel you could do it with raix:push but there was too much hacking and things looked outdated, you could most probably do it with activitree:push, with less hacking and up to date.

You can use Firebase for that, I believe.

Firebase is one component of the whole Push ecosystem and it is very much used in the existing Meteor Push packages but it cannot do the job alone, unless you write the whole Meteor - MongoDB login by yourself and also write or add your own Cordova plugin and add the NODE SDK for Firebase so you can send message out from the Meteor Server.