chore: fix bug

This commit is contained in:
2026-03-17 10:38:44 +01:00
parent af74b39b22
commit c52cc280ac
2 changed files with 29 additions and 21 deletions
+11 -4
View File
@@ -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",
);
}
}