Skip to content

Commit

Permalink
fix: onesignal env on client-side
Browse files Browse the repository at this point in the history
  • Loading branch information
jeferson-sb committed Jan 6, 2024
1 parent d475123 commit 284f6ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/env/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions src/lib/oneSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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))
}, [])

Expand Down

1 comment on commit 284f6ac

@vercel
Copy link

@vercel vercel bot commented on 284f6ac Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

whatconf – ./

whatconf.vercel.app
whatconf-git-main-jeferson-sb.vercel.app
whatconf-jeferson-sb.vercel.app

Please sign in to comment.