Ionic + Firebase with Push Notifications


#1

Hi Guys,

I saw a bunch of tutorials about making apps with Ionic + Firebase which seems as a native connection, especially with AngularFire (Firebase angular library), the Ionic team is also fond of Firebase.

I also want to use Firebase because it’s a really good, reliable and production ready BaaS (Backend as a service), and I like it being realtime as well.

But the one thing it lacks is sending push notifications, requiring you to make a server side component of your own, which is something that makes the use of firebase somehow negligible since you’re already paying for a service to be your server side.

Another option would be to pay for another service that’ll handle push notifications for you.

A different option would be to use Parse, but since I’m also interested in a webapp to talk to the backend as well, and I want in realtime, Parse won’t be a good solution for me.

What would you suggest doing in that position? Do you know if Firebase going to support push notifications in the near future? Don’t you think it is native for Firebase to implement?


#2

Ionic will be rolling out their own push notifications very shortly.

I use Firebase on a few projects now, and while push notifications would be nice, I can see why they may not want to go down that path and keep their focus on just the database aspect of things. I’ve integrated PushWoosh in with my Firebase/Ionic projects and it works quite nicely. I may probably move to Ionic’s own push service when it rolls out (and if the pricing is good).

I believe it is all about picking ‘best of breed’ services and making them work together (which is not that difficult these days).


#3

@CyberFerret thanks for the reply man,
are you using PushWoosh remote api? and if so, do you use it from the client(Ionic)? Because this will expose your api and auth key to anyone connecting fiddler to his phone allowing him to send notifications on your behalf.


#4

Valid point, but that would also expose your Firebase URL, and if you are just using auth() security restrictions, they could just as easily manipulate Firebase data once they create a login account and authenticate elsewhere… :wink:


#5

@CyberFerret so are you using their remote API or just their online console sending manual notifications? and if you’re using their remote api, are you doing it from the client?


#6

Yes, the remote API from the client (Ionic). I think with most third party push providers, you are going to have to send them a token of some sort, which is always going to be vulnerable to snooping…


#7

@CyberFerret thanks, I agree.
It’s a shame that the PushWoosh remote api isn’t exposed on the free plan with limited push count.

PushBots has a free plan with up to 1.5M notifications with their SDK, so you’re not limited to manual notifications on the free plan.


#8

If you are OK with some minimal server side setup, it’s doable. For now I have been using Ionic + Firebase + a simple NodeJS script to manage my push notifications. No need for a database on the server side, as I store the push reg id’s on Firebase and fetch it as needed.

i.e. this is what the minimal code set up would be for Android push notifications:

var gcm = require('node-gcm');
var message = new gcm.Message();
 
var sender = new gcm.Sender(API_KEY);
 
/* Pay Load */
message.addData('message',"Your message");
message.addData('title','Your Title' );
message.timeToLive = 3000
 
/* The IDs to send this too (fetched from firebase) */
var registrationIds = [];
registrationIds.push(<ids from firebase>);
 
sender.send(message, registrationIds, 4, function (result) {
    
});

#9

@praxis, Thanks for the reply!

I don’t doing server side at all, but adding a simple nodejs server with endpoints that will use your given code, will still require paying another cloud server provider like heroku/amazon in addition to firebase.


#10

My .02: wait for Ionic Push. They keep hinting it’s right around the corner. If you can’t wait, here’s what I’ve come to. PushWoosh is insanely priced, we ruled that out fast (seriously, who wouldn’t use remote API?). SNS is dirt cheap, but much harder to dev against / wrap you head around - but it’s very doable, see this tutorial. You can also host your own little server for push following this tutorial. I know you don’t want a server, but with something that performs such a small task you could host Heroku for free. Don’t rule that option out just yet, investigate SNS vs custom before making the decision. We’re using Firebase and I’ve been avoiding backend dev like the plague for the same reasons you are, but I think we’re gonna actually go with the custom server solution if Ionic Push doesn’t release soon-ish.


#11

Thanks @lefnire, It’s comforting to know that i’m not alone (:


#12

Using a script like this one in an AWS Lambda function is the perfect serverless solution. It’s what we are using for our next app…

Ionic + Firebase + Amazon Lambda + Amazon SNS

You get a free and considerable messaging quota


#13

Great article …

Excellent choice for us working backend as a Service => firebase:
Ionic + Firebase + Push notification (GCM + nodejs) = Great apps


#14

@Loyx have you done a writeup about using Ionic + Firebase + Lambda + SNS? I’d love to see how you did it. Thanks!


#15

@stewartmccoy We decided to go with Ionic.io PUSH and the rest of Ionic services, but I’m following closely the evolution of the serverless framework (maybe for my next app backend…)

If you plan to use Lambda check it out… it’s pretty awesome


#16

I want to use Ionic Push but I am having the worst time trying to get it set up.

I’ve failed to send my first push notification using Ionic dev mode in the simulator, so I’m moving forward with setting up my cert, provisioning profile, and device on the Apple Dev Center. I’m now at the point where I’m trying to build my app in Xcode.

I found this other thread Ionic run iOS deploy to emulator instead of device, but after following the advice to use ionic run ios --device, the build failed for me.

When I try to build the app from Xcode 7 with my device plugged in via USB and selected in Xcode project view, I see that ‘no code signing identities found (i.e. certificate and private key pair)’, even though I follow all of the iOS Setup instructions.

Any suggestions you have to get me unblocked would be much appreciate. I’ve spent more than 12 hours on this, heh.


#17

Luckily, I have an iOS engineer at work who pointed me in the right direction and showed me how to add my Apple Developer account. It took forever, but I finally can successfully send one-time push notification from the dashboard. Woo!


#18

Glad you solved it! :+1:


#19

#20

So guys, I built my app using firebase auth, thinking that I could use then Ionic Push to send targeted notifications.
Now that the app is built, it seems to me that Ionic push works just if using Ionic auth, am I right? Is there any way to use firebase auth + Ionic push?