mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-21 18:48:19 +00:00
fix: go back to expo tokens
This commit is contained in:
@@ -36,12 +36,11 @@ const Notifications = !Platform.isTV ? require("expo-notifications") : null;
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import { getLocales } from "expo-localization";
|
||||
import type { EventSubscription } from "expo-modules-core";
|
||||
import { getDevicePushTokenAsync } from "expo-notifications";
|
||||
import type {
|
||||
Notification,
|
||||
NotificationResponse,
|
||||
} from "expo-notifications/build/Notifications.types";
|
||||
import type { DevicePushToken } from "expo-notifications/build/Tokens.types";
|
||||
import type { ExpoPushToken } from "expo-notifications/build/Tokens.types";
|
||||
import { router, Stack, useSegments } from "expo-router";
|
||||
import * as SplashScreen from "expo-splash-screen";
|
||||
import * as TaskManager from "expo-task-manager";
|
||||
@@ -206,24 +205,24 @@ function Layout() {
|
||||
|
||||
useNotificationObserver();
|
||||
|
||||
const [pushToken, setPushToken] = useState<DevicePushToken>();
|
||||
const [expoPushToken, setExpoPushToken] = useState<ExpoPushToken>();
|
||||
const notificationListener = useRef<EventSubscription>(null);
|
||||
const responseListener = useRef<EventSubscription>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!Platform.isTV && pushToken && api && user) {
|
||||
if (!Platform.isTV && expoPushToken && api && user) {
|
||||
api
|
||||
?.post("/Streamyfin/device", {
|
||||
token: pushToken.data,
|
||||
token: expoPushToken.data,
|
||||
deviceId: getOrSetDeviceId(),
|
||||
userId: user.Id,
|
||||
})
|
||||
.then((_) => console.log("Posted device push token"))
|
||||
.then((_) => console.log("Posted expo push token"))
|
||||
.catch((_) =>
|
||||
writeErrorLog("Failed to push device push token to plugin"),
|
||||
writeErrorLog("Failed to push expo push token to plugin"),
|
||||
);
|
||||
} else console.log("No token available");
|
||||
}, [api, pushToken, user]);
|
||||
}, [api, expoPushToken, user]);
|
||||
|
||||
const registerNotifications = useCallback(async () => {
|
||||
if (Platform.OS === "android") {
|
||||
@@ -256,8 +255,8 @@ function Layout() {
|
||||
|
||||
// only create push token for real devices (pointless for emulators)
|
||||
if (Device.isDevice) {
|
||||
getDevicePushTokenAsync()
|
||||
.then((token: DevicePushToken) => token && setPushToken(token))
|
||||
Notifications?.getExpoPushTokenAsync()
|
||||
.then((token: ExpoPushToken) => token && setExpoPushToken(token))
|
||||
.catch((reason: any) => console.log("Failed to get token", reason));
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
Reference in New Issue
Block a user