Push Notifications
OneSignal for web and mobile notifications
Push Notifications
OneSignal handles notifications for both platforms.
Setup
- Create OneSignal account
- Get App IDs for web and mobile
- Add to config:
// packages/config/index.ts
platforms: {
web: {
notifications: {
oneSignal: { appId: "your-web-app-id" }
}
},
native: {
notifications: {
oneSignal: { appId: "your-mobile-app-id" }
}
}
}
Usage
Web:
import { initOneSignal } from '@repo/onesignal';
await initOneSignal();
Mobile:
import { initOneSignal } from '@repo/onesignal';
await initOneSignal();
Same API for both platforms!
Sending Notifications
// Server-side
await sendNotification({
title: "Hello",
message: "New update available",
userIds: ["user123"]
});
That's it - OneSignal handles the rest.