gpt4 book ai didi

javascript - Sendbird、cordova 推送通知功能

转载 作者:搜寻专家 更新时间:2023-11-01 04:35:01 24 4
gpt4 key购买 nike

我正在使用 Sendbird 构建聊天应用程序和 cordova,但是他们似乎为所有平台提供了推送通知的 api,来自 Javascript 的平台除外。 .他们有 Android 的推送通知, ios , Unity.Net + Xamarin. .因为我是新手,所以我不确定 JS api 是否不完整,或者他们有不实现它的设计决策。

有人可以帮助我获取 Sendbird 和 Cordova 的推送通知吗,我假设 FCM将被要求。

最佳答案

我找到了一个零散的解决方案。

您将需要使用 platfrom API并安装以下两个命令。

  1. cordova 插件添加 phonegap-plugin-push --variable SENDER_ID="xxxxxxxx"--save
  2. cordova 插件添加 cordova-plugin-fcm

在您的项目中执行上述操作之前,您需要针对 Android 执行步骤 1 和 2。和/或 1,2 和 3 对于 iOs .

一旦全部完成,您应该将以下两个文件放在项目的根目录中,这样“www”就层次结构而言与这些文件同级。

  1. google-services.json
  2. GoogleService-Info.plist

一旦完成,请按照 phone-gap-push 中的此步骤操作.理想情况下,您只需要以下代码片段即可注册 token 。

const push = PushNotification.init({
android: {
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});

push.on('registration', (data) => {
// what you get back in your data variable will be two things
// registrationId and registrationType

// Use the returned values to make the platform api call to sendbird
});

注意事项 sendbird 仅在您离线时发送推送通知。用于推送通知的 iO 或 Android 文档很好地突出了这些免责声明。

By setting up push notification service to an app, your app users can receive messages even when they are offline. Typically, you might want users to receive push notifications after their app goes into the background. SendBird SDK automatically detects if your app enters the background and updates the user's connection status to Disconnected. Therefore, in normal cases, you do not have to call disconnect explicitly.

Sendbird 上有一个推送通知的 corodva/phonegap/javascript 实现。

不,我不能告诉你为什么 Sendbird 没有类似的文档!如果有人有更好更有效的方法,我会洗耳恭听。

关于javascript - Sendbird、cordova 推送通知功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48135824/

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