chore: fix bug
This commit is contained in:
@@ -19,7 +19,9 @@ function handleRegistrationError(errorMessage: string) {
|
||||
Alert.alert("Push Notification Error", errorMessage);
|
||||
}
|
||||
|
||||
export async function registerForPushNotifications(): Promise<string | undefined> {
|
||||
export async function registerForPushNotifications(): Promise<
|
||||
string | undefined
|
||||
> {
|
||||
if (Platform.OS === "android") {
|
||||
await Notifications.setNotificationChannelAsync("default", {
|
||||
name: "default",
|
||||
@@ -36,14 +38,17 @@ export async function registerForPushNotifications(): Promise<string | undefined
|
||||
}
|
||||
|
||||
if (Device.isDevice) {
|
||||
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
||||
const { status: existingStatus } =
|
||||
await Notifications.getPermissionsAsync();
|
||||
let finalStatus = existingStatus;
|
||||
if (existingStatus !== "granted") {
|
||||
const { status } = await Notifications.requestPermissionsAsync();
|
||||
finalStatus = status;
|
||||
}
|
||||
if (finalStatus !== "granted") {
|
||||
handleRegistrationError("Permission not granted to get push token for push notification!");
|
||||
handleRegistrationError(
|
||||
"Permission not granted to get push token for push notification!",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const projectId =
|
||||
@@ -64,6 +69,8 @@ export async function registerForPushNotifications(): Promise<string | undefined
|
||||
handleRegistrationError(`${e}`);
|
||||
}
|
||||
} else {
|
||||
handleRegistrationError("Must use physical device for push notifications");
|
||||
handleRegistrationError(
|
||||
"Must use physical device for push notifications",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user