init
This commit is contained in:
20
frontend/plugins/push-context.client.ts
Normal file
20
frontend/plugins/push-context.client.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const { token } = useAuth();
|
||||
const anonymousClientId = useState<string | null>("anonymous-push-client-id", () => null);
|
||||
const { syncServiceWorkerContext, syncNativeSubscription, isNativeApp } = usePush();
|
||||
|
||||
if (isNativeApp()) {
|
||||
await syncNativeSubscription();
|
||||
} else {
|
||||
await syncServiceWorkerContext();
|
||||
}
|
||||
|
||||
watch([token, anonymousClientId], () => {
|
||||
if (isNativeApp()) {
|
||||
void syncNativeSubscription();
|
||||
return;
|
||||
}
|
||||
|
||||
void syncServiceWorkerContext();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user