简体   繁体   中英

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.
  • I'm using PubNub to publish APNS and FCM notifications.
  • I'm using cordova-plugin-device to obtain the device UUID.

I need to request permission from the user to allow push notifications.

How do I do that for Android and iOS, respectively?

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. 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?

You could try cordova-plugin-permission

This plugin provides the ability to verify and request grants for Android app permissions.

For iOS, I believe you need to merge your plist to add the permission you request

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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