I am having an issue with Permissions.askAsync for notifications.
const status = await Permissions.askAsync(Permissions.NOTIFICATIONS)
When
use app-setting link to open setting for manual permission because ios do not allow us to give permission from prompt if user reject permission
Linking.openURL('app-settings:')
like this
import React, { Component } from "react";
import { Text, StyleSheet, View, Linking, Alert } from "react-native";
import * as Permissions from "expo-permissions";
export default class App extends Component {
componentDidMount() {
this.checkPushNotificationState();
}
checkPushNotificationState = async () => {
let { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
if (existingStatus !== "granted") {
const status = await Permissions.askAsync(Permissions.NOTIFICATIONS);
existingStatus = status.status;
}
if (existingStatus !== "granted") {
Alert.alert(
"No Notification Permission",
"please goto setting and on notification permission manual",
[
{ text: "cancel", onPress: () => console.log("cancel") },
{ text: "Allow", onPress: () => Linking.openURL("app-settings:") },
],
{ cancelable: false }
);
return;
}
};
Note: you should use double permission for The Right Way to Ask Users for Mobile Permissions