Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates API to user model #2

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Updates API to user model #2

wants to merge 12 commits into from

Conversation

iAmWillShepherd
Copy link
Contributor

@iAmWillShepherd iAmWillShepherd commented Mar 29, 2023

I updated to the latest version of the OneSignal React SDK, hoping to get web push functionality for iOS. Still, the update makes use of the upcoming user model API.

@vercel
Copy link

vercel bot commented Mar 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onesignal-next-push ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2023 7:31pm

@iAmWillShepherd
Copy link
Contributor Author

iAmWillShepherd commented Mar 29, 2023

My project worked until I updated to the latest version of the SDK. Now, I'm getting an error stating the window object is not defined because Next.js does SSR on the initial page render. The server doesn't have a window object, so we should do a check to ensure it exists; otherwise, perform a no-op.

Screenshot 2023-03-29 at 11 22 40 AM

Error after updating to User Model SDK
warn  - Fast Refresh had to perform a full reload due to a runtime error.
error - ReferenceError: window is not defined
    at Object.<anonymous> (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/react-onesignal/dist/index.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.react-onesignal (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:197:18)
    at __webpack_require__ (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./pages/hooks/onesignal.tsx:8:73)
    at Object../pages/hooks/onesignal.tsx (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:110:1)
    at __webpack_require__ (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./pages/index.tsx:11:74)
    at Object../pages/index.tsx (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:121:1)
    at __webpack_require__ (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:218:39)
    at /Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:219:28
    at Object.<anonymous> (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/.next/server/pages/index.js:222:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.requirePage (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/require.js:88:12)
    at /Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/load-components.js:48:73
    at async Object.loadComponents (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/load-components.js:48:26)
    at async DevServer.findPageComponents (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/next-server.js:563:36)
    at async DevServer.findPageComponents (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/dev/next-dev-server.js:1041:20)
    at async DevServer.renderPageComponent (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/base-server.js:951:24)
    at async DevServer.renderToResponse (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/base-server.js:980:32)
    at async DevServer.pipe (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/base-server.js:407:25)
    at async Object.fn (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/next-server.js:759:21)
    at async Router.execute (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/router.js:253:36)
    at async DevServer.run (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/base-server.js:384:29)
    at async DevServer.run (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/dev/next-dev-server.js:743:20)
    at async DevServer.handleRequest (/Users/iamwill/code/@onesignalDevelopers/onesignal-next-push-sample/node_modules/next/dist/server/base-server.js:322:20) {
  page: '/'
}

Refer to Next.js docs for details on rendering environments.

@iAmWillShepherd
Copy link
Contributor Author

Init works, but still figuring out how to get event handler to fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant