简体   繁体   English

为 Cordova iOS 和 Android 请求推送通知权限?

[英]Request Push Notification Permissions for Cordova iOS and Android?

I'm stuck and would greatly appreciate your help.我被卡住了,非常感谢您的帮助。

Details细节

  • I have a working React/Cordova app.我有一个可用的 React/Cordova 应用程序。
  • I'm using PubNub to publish APNS and FCM notifications.我正在使用 PubNub 发布 APNS 和 FCM 通知。
  • I'm using cordova-plugin-device to obtain the device UUID.我正在使用 cordova-plugin-device 来获取设备 UUID。

I need to request permission from the user to allow push notifications.我需要请求用户的许可才能允许推送通知。

How do I do that for Android and iOS, respectively?我如何分别为 Android 和 iOS 做到这一点?

I've tried cordova-plugin-firebase, cordova-plugin-firebasex, and phonegap-plugin-push but they aren't working with cordova@9.x and are overkill for my purposes.我已经尝试过cordova-plugin-firebase、cordova-plugin-firebasex 和phonegap-plugin-push,但它们不能与cordova@9.x 一起使用并且对我的目的来说太过分了。 I just want to ask for push notification permission, not send notifications directly from the device.我只想请求推送通知权限,而不是直接从设备发送通知。

Is there an easy or simple way to do this for iOS and Android with Cordova?是否有一种简单的方法可以使用 Cordova 为 iOS 和 Android 执行此操作?

You could try cordova-plugin-permission你可以试试cordova-plugin-permission

This plugin provides the ability to verify and request grants for Android app permissions.此插件提供验证和请求授予 Android 应用程序权限的能力。

For iOS, I believe you need to merge your plist to add the permission you request对于 iOS,我相信您需要合并您的 plist 以添加您请求的权限

 <edit-config file="*-Info.plist" mode="merge" target="[THE PERMISSION]">
        <string>[string explaining why you need it]</string>
  </edit-config>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM