mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-28 19:36:29 +01:00
fix: generate expo push tokens for real device only
This commit is contained in:
@@ -32,6 +32,7 @@ const BackgroundFetch = !Platform.isTV
|
|||||||
? require("expo-background-fetch")
|
? require("expo-background-fetch")
|
||||||
: null;
|
: null;
|
||||||
import * as FileSystem from "expo-file-system";
|
import * as FileSystem from "expo-file-system";
|
||||||
|
import * as Device from "expo-device";
|
||||||
const Notifications = !Platform.isTV ? require("expo-notifications") : null;
|
const Notifications = !Platform.isTV ? require("expo-notifications") : null;
|
||||||
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
|
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
|
||||||
import { Stack, router, useSegments } from "expo-router";
|
import { Stack, router, useSegments } from "expo-router";
|
||||||
@@ -331,9 +332,12 @@ function Layout() {
|
|||||||
await registerBackgroundFetchAsyncSessions();
|
await registerBackgroundFetchAsyncSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifications?.getExpoPushTokenAsync()
|
// only create push token for real devices (pointless for emulators)
|
||||||
.then((token: ExpoPushToken) => token && setExpoPushToken(token))
|
if(Device.isDevice) {
|
||||||
.catch((reason: any) => console.log("Failed to get token", reason));
|
Notifications?.getExpoPushTokenAsync()
|
||||||
|
.then((token: ExpoPushToken) => token && setExpoPushToken(token))
|
||||||
|
.catch((reason: any) => console.log("Failed to get token", reason));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user