Firebase Cloud Messaging for push notifications (both iOS and Android)


#1

I gave up on Ionic Push during the alpha phase and when I revisited it during beta, I still couldn’t get it to work. Just this last week, Firebase announced Firebase Cloud Messaging for iOS and Android, which allows for push notifications. Check out more info here: https://firebase.google.com/docs/notifications/

Curious if anybody has implemented this yet? Thoughts on the service?

I’m especially excited about this because I’m already using Firebase’s real-time database for iOS.


Run APP like WhatsApp
#2

until someone writes a native module for it, it is useless… there are only native IOS and Androild SDKs


#3

haha, shiiiiit. Yep, good call out. Ah, what a bummer. Curious, have you tried the Ionic Push Beta? Should I give it another try now that it’s been out a few months?

I’m also considering using Node.js/Express to using APNS.


#4

Same problem here, was unable to implement Ionic Push for my Ionic 2 App, so I finally used onesignal last week which is working fine so far and is free also.


#5

I am just looking for this and i have found this:
https://www.npmjs.com/package/cordova-plugin-fcm
I’ll report when i test it.


#6

Thanks for the plugin! I did some tests on #ionic-2 and it works great on Android devices (I will test it on iOS next week).
EDIT: on iOS it works too:)


#7

Hi, can you please share your code.
Thanks


#8

Hi! Here is a demo based on tutorial template:


It works on Android and iOS devices.


#9

Thanks for posting this sample code.

Have you managed to get this working with the FCM REST API? Android and iOS work just fine for me using the FCM console, but I’ve only been able to get the REST API to work for Android, not iOS.


#10

does’t work for both android and ios phones, have you created two apps in google cloud (one for android and one for ios ) if so have you done some native codes ! thanks for the code by the way.


#11

I got these Errors when I build android
FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘android’.

Could not resolve all dependencies for configuration ‘:_debugCompile’.
Could not find com.google.firebase:firebase-core:9.2.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.pom
https://repo1.maven.org/maven2/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.jar
https://jcenter.bintray.com/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.pom
https://jcenter.bintray.com/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.jar
file:/Users/mac/.m2/repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.pom
file:/Users/mac/.m2/repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.jar
file:/Users/mac/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.pom
file:/Users/mac/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.jar
file:/Users/mac/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.pom
file:/Users/mac/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/9.2.0/firebase-core-9.2.0.jar
Required by:
:android:unspecified
Could not find com.google.firebase:firebase-messaging:9.2.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.pom
https://repo1.maven.org/maven2/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.jar
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.pom
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.jar
file:/Users/mac/.m2/repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.pom
file:/Users/mac/.m2/repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.jar
file:/Users/mac/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.pom
file:/Users/mac/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.jar
file:/Users/mac/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.pom
file:/Users/mac/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/9.2.0/firebase-messaging-9.2.0.jar
Required by:
:android:unspecified


#12

Hi! I have the same problem. Did you fixed it?

Thank you!


#13

Thank you! Awesome and useful example, I was able to send a notification to both iOS and Android with FCM and cordova-plugin-fcm.


#14

@Mounir1badi and @Jorchg, I have the same issue, did you find a solution for it?


How to solve build failure with cordova-plugin-fcm?
#15

@Mounir1badi @Jorchg
I had to install with the Android SDK Manager under Extras this packages:

This resolves me the issue with the “Could not find com.google.firebase:firebease-core:x.x.x” error.

But after that I got this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugGoogleServices'.
> No matching client found for package name 'com.ionicframework.webclientionic2433370'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

The solution is, you have to set config <widget id=" in config.xml to your “package_name” from google-service.json you configured in firebird configuration.


#16

Hello guys!
Any tutorials on ionic 1 to emplement FCM ?


#17

Does it work even when the app is closed (not running)?


#18

Naaaa im missed, it not works if app closed…

Opened some ISSUES on github. No solutions for this yet


#19

facing same issue. anyone find any solution


#20

Anyone please support me my app will be struggle in push. I m using ionic1 to developing. Please give me the FCM sample code for the push. My project is 90% completed Push only in pending.