0

I'm using official react-native marketing cloud sdk for push notification integration. However as I've seen in the example as well ( https://github.com/salesforce-marketingcloud/react-native-marketingcloudsdk/blob/master/example/App.tsx ) we specifically need to request for Push Permission only for Android. So, for iOS it's being handled from native code.

How can I disable the push permission from native code and request from a library ? I'm using react-native-permissions. Because I need to show a custom modal before the push permission requests mentioning about the use cases.

1 Answer 1

0

I will try to explain how we solved the problem in our case. Inside of App.js you first import the react-native-permissions:

import { PERMISSIONS, request } from "react-native-permissions";

Then you can create a simple askForPermissions method like this:

askForPermissions(permission) { request(permission).then((result) => { console.log('Permission for POST NOTIFICATIONS is: ', result) }) }

After that we called the method inside of componentDidMount() like shown in the code below:

async componentDidMount() { if(Platform.OS === 'android'){ this.askForPermissions(PERMISSIONS.ANDROID.POST_NOTIFICATIONS) } else { console.log('No permissions allowed.') } // other code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .