chore: add notification telegram

This commit is contained in:
2026-03-24 11:51:22 +01:00
parent a8eeb55e72
commit 79c050d689
15 changed files with 424 additions and 253 deletions
@@ -1,38 +0,0 @@
import * as Notifications from "expo-notifications";
import * as Device from "expo-device";
import { Platform } from "react-native";
/**
* Demande les permissions et retourne le token Expo push.
* Retourne null si non supporté (simulateur, refus de permission).
*/
export async function getExpoPushToken(): Promise<string | null> {
if (!Device.isDevice) return null;
const { status: existing } = await Notifications.getPermissionsAsync();
let finalStatus = existing;
if (existing !== "granted") {
const { status } = await Notifications.requestPermissionsAsync();
finalStatus = status;
}
if (finalStatus !== "granted") return null;
if (Platform.OS === "android") {
await Notifications.setNotificationChannelAsync("orders", {
name: "Nouvelles commandes",
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
sound: "default",
});
}
try {
const tokenData = await Notifications.getExpoPushTokenAsync();
return tokenData.data;
} catch {
// Google Play Services absent (ex: GrapheneOS) — push non disponible
return null;
}
}