Skip to content

feat: integrate OneSignal for push notifications#167

Open
Antoni-Czaplicki wants to merge 1 commit into
mainfrom
onesignal
Open

feat: integrate OneSignal for push notifications#167
Antoni-Czaplicki wants to merge 1 commit into
mainfrom
onesignal

Conversation

@Antoni-Czaplicki

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 1, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR integrates OneSignal web push notifications into the Next.js app by adding a client-side initialization component, registering the required service worker, and wiring the init into the root layout.

Changes:

  • Add a OneSignalInit client component that initializes OneSignal using NEXT_PUBLIC_ONESIGNAL_APP_ID.
  • Render OneSignalInit from src/app/layout.tsx so it runs globally.
  • Add public/OneSignalSDKWorker.js, react-onesignal dependency, and introduce .env.example (plus a small .gitignore update).

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/one-signal-init.tsx New client component to initialize OneSignal on mount.
src/app/layout.tsx Mounts OneSignalInit in the root layout.
public/OneSignalSDKWorker.js Adds OneSignal service worker loader via importScripts.
package.json Adds react-onesignal dependency.
package-lock.json Locks react-onesignal dependency version/resolution.
.gitignore Ignores .idea/ and ensures .env.example remains tracked.
.env.example Adds example env var placeholder for OneSignal App ID.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +11
const appId = process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID;

if (appId === undefined) {
console.error("OneSignal app ID is not defined, skipping initialization");

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

NEXT_PUBLIC_ONESIGNAL_APP_ID can be defined but empty (e.g., .env.example sets it to an empty value). In that case this code will still call OneSignal.init with an empty appId and then log an initialization failure. Treat empty/whitespace values as “not configured” and skip initialization (e.g., validate it’s a non-empty string) to avoid noisy errors/misleading behavior.

Suggested change
const appId = process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID;
if (appId === undefined) {
console.error("OneSignal app ID is not defined, skipping initialization");
const rawAppId = process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID;
const appId = typeof rawAppId === "string" ? rawAppId.trim() : undefined;
if (!appId) {
console.error("OneSignal app ID is not defined or empty, skipping initialization");

Copilot uses AI. Check for mistakes.
Comment thread .env.example
@@ -0,0 +1 @@
NEXT_PUBLIC_ONESIGNAL_APP_ID= No newline at end of file

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

This example env file only includes NEXT_PUBLIC_ONESIGNAL_APP_ID, but the app also reads other env vars (e.g. FEEDBACK_FORM_URL, API_URL, JUWE_*_URL). To keep onboarding/docs accurate, include the full set of supported env vars here (or rename/scope this file if it’s intentionally OneSignal-only) and update the README section that currently instructs creating an .env with only FEEDBACK_FORM_URL.

Suggested change
NEXT_PUBLIC_ONESIGNAL_APP_ID=
# OneSignal configuration
NEXT_PUBLIC_ONESIGNAL_APP_ID=
# Feedback form configuration
FEEDBACK_FORM_URL=
# Backend API base URL
API_URL=
# JUWE-related service URLs
# Add all JUWE_*_URL variables required by your deployment, for example:
# JUWE_PORTAL_URL=
# JUWE_ADMIN_URL=
# JUWE_API_URL=

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants