Setup for Ionic Cloud using FCM now that GCM not a

2019-07-27 18:15发布

问题:

I noticed while trying to enable GCM that it has been replaced with FCM. So after some searching I found that phonegap-plugin-push has a version 2.x for use with FCM, which I installed using the last commit hash, but I don't know how to enable FCM on the Google Cloud Platform for an Ionic application. Do you use web setup? Seems to only talk about Google Chrome in the description, and then it explains how to add Firebase to an Android application, but I'm trying to do this the Ionic framework.

Has anyone created a new project and been forced to use FCM, and could provide some help? It seems to be the only missing piece, since I appear to receive a token on application startup after following the docs and adding the Ionic Cloud initialization to a config block, and then registering the token in a run block, but no notifications sent from Ionic Cloud's dashboard are received or caught in a $scope event.

回答1:

You can still get to GCM, but only if you search for google cloud messaging using the search input of their dashboard otherwise all the Google Cloud Messaging links in their dashboard redirect you to Firebase Cloud Messaging (FCM). Though Google highly suggests that all new applications use FCM the search will provide a drop down result that does redirect you to the old GCM API view that contains the Enable API link. FCM requires setup, and GCM requires you click enable remaining with GCM for now seems like a no brainer unless you need the new features.



回答2:

There is a cordova plugin for FCM right now.

https://github.com/fechanique/cordova-plugin-fcm

Unfortunately, at least for me, and from what I can see in the issues on github, there seems to be some issues with the callback not firing when receiving a notification while the app is closed/in the background.

You do receive the notification, but you're unable to do anything with the data which is a big deal.

The Phonegap-Push plugin is currently integrating FCM w/ 2.0, but it's super buggy.