Firebase云消息与Ionic应用程序
我正在使用离子框架(web技术)开发Android / ios应用程序,并且希望在新的firebase功能FCM的帮助下添加推送通知。
I am developing android/ios app using ionic framework (web technologies) and I want to add Push Notification with the help of new firebase feature FCM.
我正在查看以下文档:
https://firebase.google.com/docs/cloud-messaging/chrome/client#project-setup
表示:
- Chrome中的网站可以通过服务人员和网络实现推送消息
- 按照Webpush标准显示。 Chrome应用和扩展程序可以通过chrome.gcm
API直接访问FCM服务。
这是否意味着我可以在我的离子应用程序中使用它的Android / ios,因为应用程序是使用cordova构建的。
感谢
我知道这个问题是侏罗纪已经,但只是为了未来的移动开发人员使用Ionic框架的信息。
I know this question is jurassic already but just for information of future mobile developers using Ionic framework. This is 100% working now, I've been using it for the past 3 weeks.
所有你需要的是添加这个插件
All you need is to add this 3 plugin
ionic plugin add cordova-plugin-inappbrowser
ionic plugin add cordova-plugin-fcm
ionic plugin add cordova-plugin-velda-devicefeedback
接下来,转到 Firebase Console 和
- 创建新项目并为其命名;
- 选择您喜欢的平台(ios / android);
- 添加您的包名称您的
应用程式:您可以在 config.xml (例如
id =com.ionicframework.someTest123)中看到它。
- Create a New Project and give it a name;
- Select which platform you like (ios/android);
- Add your Package Name, which is the id of your app: you can see it in your config.xml (something like id="com.ionicframework.someTest123").
Firebase控制台会为您提供一个名为 google-services.json 的文件。
The Firebase Console will give you a file named google-services.json .
- 将它粘贴到 platforms / android / 目录中
- 运行
ionic在您的CLI上构建android
- Paste it in the platforms/android/ directory
- Run
ionic build android
on your CLI
现在可以转到通知页面>新消息
You can now go to Notifications Page > New Message
请务必在发送推送
通知之前选择您添加的应用(应用的ID)。
Make sure to select the app (id of the app) you added before sending push notifications.