Sam*_*num 5 push-notification apple-push-notifications ionic-framework capacitor
我的 Ionic 5 应用程序想要发送推送通知。我能找到的唯一指南是在 Ionic + Angular 应用程序中使用带有 Firebase 的推送通知
为什么需要 Firebase?我可以在没有 Firebase 的情况下发送推送通知吗?
反正我试过这个设置。我没有走多远。
该指南有以下代码:
// Request permission to use push notifications
// iOS will prompt user and return if they granted permission or not
// Android will just grant without prompting
PushNotifications.requestPermission().then( result => {
if (result.granted) {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// Show some error
}
});
Run Code Online (Sandbox Code Playgroud)
但是,Typescript 抱怨正确的方法requestPermissions()不是requestPermission().
在 XCode 中运行时两者都失败,可能是因为我没有设置 pod。
Ionic 5 + Capacitor 在没有 Firebase 的情况下发送推送通知有哪些选择?
编辑:
该指南现已更新至电容器 3。
可以在此处找到电容器 2 指南
旧:指南已更新到电容器 2,但电容器 2 仍处于测试阶段。
使用下一个标签安装它
npm install @capacitor/cli@next
npm install @capacitor/core@next
npm install @capacitor/ios@next
npm install @capacitor/android@next
Run Code Online (Sandbox Code Playgroud)
Capacitor 默认使用 APNS,因此如果您不在 AppDelegate.swift 中进行更改,它应该可以正常工作。
| 归档时间: |
|
| 查看次数: |
6099 次 |
| 最近记录: |