gpt4 book ai didi

android - 电容器不接收 android 特定的推送通知

转载 作者:行者123 更新时间:2023-12-05 00:20:57 24 4
gpt4 key购买 nike

我尝试对我的 Ionic4-Capacitor-App 实现推送通知。

在应用程序中,我有以下代码:

PushNotifications.register();
PushNotifications.createChannel({ id: '1', description: '2019', importance: 2, name: '2019'});
PushNotifications.addListener('pushNotificationReceived', (notification) => {
console.debug(JSON.stringify(notification));
});

使用 POSTMAN,我尝试发送以下消息:
{
"to": "<User-Token>",
"notification": {
"title": "Default Title",
"body": "Default Body"
},
"android": {
"notification": {
"title": "Android Title",
"body": "Android Title",
"channel_id": "1"
}
}
}

Here is the documentation I used.

我收到的通知将“默认标题”作为标题,将“默认正文”作为正文。
我希望它有“Android Title”和“Android Body”。此外,通知不会推送到 channel 1,而是推送到杂项。

当我省略“根”通知部分时,根本不会显示任何通知。

最佳答案

对于每个面临同样问题的人:
以下是我通过 Postman 发送 Firebase 云消息的配置步骤。

谷歌云配置:

  • 前往:https://console.cloud.google.com/apis/credentials/consent
  • 将 getpostman.com 添加到授权域
  • 前往:https://console.cloud.google.com/apis/credentials
  • 添加新的 OAuth-Client-ID
  • 选择 Webapplication 并为其命名。
  • 将授权重定向 URL 设置为 https://www.getpostman.com/oauth2/callback并保存。
  • 为这个账号下载Json

  • postman 配置:
  • 将请求类型设置为 POST
  • 输入网址:https://fcm.googleapis.com/v1/projects/ {your-firebase-project-name}/messages:发送
  • 转到授权,选择类型 OAuth 2.0 并单击“获取新访问 token ”
  • 授权类型授权码
  • 回调地址:https://www.getpostman.com/oauth2/callback
  • 验证 URL:[来自 json 文件的 auth_uri]
  • 访问 token URL:[json 文件中的 token_uri]
  • 客户端 ID:[来自 json 文件的客户端 ID]
  • 客户端密码:[json 文件中的client_secret]
  • 范围:https://www.googleapis.com/auth/firebase.messaging
  • 状态:[空]
  • 客户端身份验证:作为基本身份验证 header 发送

  • 完成这些步骤后,您应该能够按照本文档中的说明发送消息: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send

    关于android - 电容器不接收 android 特定的推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55966908/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com