我正在使用 ionic 框架(网络技术)开发 android/ios 应用程序,我想在新的 firebase 功能 FCM 的帮助下添加推送通知。
现在我正在查看以下文档:
https://firebase.google.com/docs/cloud-messaging/chrome/client#project-setup
上面写着:
- Websites in Chrome can implement push messaging through service workers and web
- app manifests following the Webpush standard. Chrome apps and extensions can access the FCM service directly through chrome.gcm
API.
这是否意味着我可以在 android/ios 的 ionic 应用程序中使用它,因为应用程序是使用 cordova 构建的?
如果有任何实现的示例,我可以看到和学习,这将非常有帮助。
谢谢
最佳答案
我知道这个问题已经很幼稚了,但仅供 future 使用 Ionic 框架的移动开发人员引用。现在 100% 有效,过去 3 周我一直在使用它。
您所需要的只是添加这 3 个插件
ionic plugin add cordova-plugin-inappbrowser
ionic plugin add cordova-plugin-fcm
ionic plugin add cordova-plugin-velda-devicefeedback
接下来,转到Firebase Console和
- 创建一个新项目并为其命名;
- 选择您喜欢的平台(ios/android);
- 添加您的包名称,这是您的 ID 应用程序:您可以在 config.xml 中看到它(类似于 id="com.ionicframework.someTest123")。
Firebase 控制台将为您提供一个名为 google-services.json 的文件。
- 将其粘贴到platforms/android/目录中
- 在 CLI 上运行
ionic build android
您现在可以前往通知页面 > 新消息
发送推送前请务必选择您添加的应用程序(应用程序的 ID) 通知。
关于cordova - 使用 Ionic 应用程序进行 Firebase 云消息传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653251/