Overview
Remote push notifications allow you to send messages to users even when your app is closed. Unlike local notifications, these are triggered from your server and can be targeted to specific users, groups, or all users based on your backend logic.
Prerequisites
OneSignal Setup
-
Create a OneSignal account
-
Create a new app/website in OneSignal
-
Configure iOS and Android platforms
Despia Configuration
-
Have your Despia project ready
-
Link it to your WeWeb application
WeWeb Setup
-
Verify installation: Assets → Library → check for "Despia"
Platform Configuration
iOS Setup
Step 1: Create Apple Push Key
-
Go to Apple Developer
-
Navigate to Keys
-
Create new key with name (e.g., "MyApp Push")
-
Enable Apple Push Notifications service
-
Download the .p8 file (keep it secure - can only download once)
Step 2: Configure OneSignal for iOS
-
In OneSignal, select Apple iOS platform
-
Upload your .p8 file
-
Enter Key ID (from Apple Developer)
-
Enter Team ID (top right in Apple Developer)
-
Enter Bundle ID (from Despia → Publish App)
-
Select Native iOS (not React Native)
-
Save and continue
Android Setup
Step 1: Create Firebase Project
-
Go to Firebase Console
-
Create new project
-
Navigate to Project Settings → Cloud Messaging
-
Verify FCM API v1 is enabled
Step 2: Generate Service Account
-
Go to Service Accounts tab
-
Click Generate new private key
-
Download the JSON file (keep secure)
Step 3: Configure OneSignal for Android
-
In OneSignal, activate Google Android
-
Upload Firebase service account JSON
-
Select Native Android
-
Save and continue
Despia Integration
Add OneSignal App IDs
-
Copy App ID from OneSignal
-
In Despia editor, paste into:
-
iOS Application ID field
-
Android Application ID field (often same ID)
-
-
Save configuration
WeWeb Implementation
Step 1: Add Despia Plugin Component
-
Click Add → Assets
-
Drag Despia plugin to top of page
-
This exposes the OneSignal Player ID variable
Step 2: Access Player ID
The plugin provides access to:
-
onesignalplayerid
: Unique device identifier -
Use this to target specific devices
Step 3: Store Player ID on Login
During user authentication:
-
Add Player ID parameter to login request
-
Store in your database linked to user account
-
Handle multiple devices per user (use array/table)
Backend Integration
API Configuration Example (Xano)
-
Create external API endpoint
-
Import OneSignal cURL command
-
Configure with:
-
App ID: From OneSignal
-
API Key: From OneSignal Settings → Keys & IDs
-
Player IDs: Array of target devices
-
Message content: Title and body
-
curl -X POST https://onesignal.com/api/v1/notifications \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization: Basic YOUR_REST_API_KEY" \
-d '{
"app_id": "ONESIGNAL-APP-ID",
"include_player_ids": ["PLAYER-ID"],
"headings": {"en": "Hello"},
"contents": {"en": "This is a test notification from Despia"}
}'
Sending Notifications
Target specific users by:
-
Query user's linked Player IDs
-
Include in OneSignal API request
-
Send notification to all user's devices
Player ID Management
Important Considerations
-
Player IDs may change when users switch accounts
-
One user can have multiple Player IDs (multiple devices)
-
Handle device switching logic in backend
Best Practices
-
On Login: Update Player ID association
-
On Logout: Consider removing Player ID
-
Account Switching: Transfer Player ID to new account
-
Multiple Devices: Store as array/list reference
Publishing & Deployment
When to Rebuild App
Rebuild in Despia when changing:
-
OneSignal App IDs
-
Start URL
-
App name or icon
-
Any Despia editor settings
Over-the-Air Updates
WeWeb changes update automatically:
-
No rebuild needed for WeWeb changes
-
Instant deployment to all users
-
No App Store resubmission
Testing Push Notifications
-
Deploy app with OneSignal configuration
-
Install on test device via TestFlight/Beta
-
Copy Player ID from app
-
Send test notification from backend
-
Verify receipt on device
Common Use Cases
E-commerce
-
Order status updates
-
Shipping notifications
-
Promotional offers
-
Cart abandonment reminders
Social Apps
-
New messages
-
Friend requests
-
Content interactions
-
Event reminders
Business Apps
-
Task assignments
-
Meeting reminders
-
Approval requests
-
System alerts
Troubleshooting
Notifications not received:
-
Verify OneSignal configuration
-
Check Player ID is correct
-
Ensure app permissions granted
-
Test with OneSignal dashboard first
Wrong user receiving notifications:
-
Check Player ID associations
-
Verify account switching logic
-
Review database relationships
iOS specific issues:
-
Verify .p8 key is valid
-
Check bundle ID matches
-
Ensure push entitlement enabled
Android specific issues:
-
Verify FCM is enabled
-
Check Firebase configuration
-
Review service account permissions
For additional support or questions, please contact our support team at support@despia.com