From 284f6ac9b481a68312e92736a8d8342545931d0a Mon Sep 17 00:00:00 2001 From: "Jeferson S. Brito" Date: Sat, 6 Jan 2024 17:27:03 -0300 Subject: [PATCH] fix: onesignal env on client-side --- src/env/env.mjs | 7 ++++--- src/lib/oneSignal.ts | 3 --- src/pages/index.tsx | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/env/env.mjs b/src/env/env.mjs index b566c44..45a0bd8 100644 --- a/src/env/env.mjs +++ b/src/env/env.mjs @@ -24,15 +24,16 @@ const server = z.object({ DISCORD_CLIENT_SECRET: z.string(), GOOGLE_CLIENT_ID: z.string(), GOOGLE_CLIENT_SECRET: z.string(), - ONESIGNAL_APP_ID: z.string(), - ONESIGNAL_SAFARI_ID: z.string() }) /** * Specify your client-side environment variables schema here. This way you can ensure the app isn't * built with invalid env vars. To expose them to the client, prefix them with `NEXT_PUBLIC_`. */ -const client = z.object({}) +const client = z.object({ + ONESIGNAL_APP_ID: z.string(), + ONESIGNAL_SAFARI_ID: z.string() +}) /** * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. diff --git a/src/lib/oneSignal.ts b/src/lib/oneSignal.ts index 6fcac5e..58bfc00 100644 --- a/src/lib/oneSignal.ts +++ b/src/lib/oneSignal.ts @@ -11,9 +11,6 @@ export const initializeOneSignal = async ( appId: env.ONESIGNAL_APP_ID, safari_web_id: env.ONESIGNAL_SAFARI_ID, allowLocalhostAsSecureOrigin: true, - notifyButton: { - enable: true, - }, }); await OneSignal.login(userId); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 40b21b2..34642b9 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -15,7 +15,6 @@ import styles from './index.module.css' import { useAuth } from '@/hook/useAuth' import { useToast } from '@/hook/useToast' -import { isProd } from '@/lib/detectEnv' import { initializeOneSignal } from '@/lib/oneSignal' const Home: NextPage = () => { @@ -76,6 +75,7 @@ const Home: NextPage = () => { initializeOneSignal(session.user.id, () => { oneSignalInitiated.current = true; + console.log('window.OneSignal.initialized', window?.OneSignal?.initialized) }, (e) => console.error(e)) }, [])