Push Notifications
Push Notification Getting Started
Learn how to send push notifications across iOS, Android, and web platforms with the OMX Push API.
Push Notifications
Build with confidence
Send engaging push notifications across all platforms with the OMX Push Notification API. Support for iOS, Android, web browsers, and desktop applications with intelligent delivery optimization and comprehensive analytics.
Installation & Setup
Get started with push notifications in just a few steps.
1
Install the package
Add the push notification module to your project
typescript
1# npm
2npm install @omx-sdk/core @omx-sdk/push-notification
3
4# yarn
5yarn add @omx-sdk/core @omx-sdk/push-notification
6
7# pnpm
8pnpm add @omx-sdk/core @omx-sdk/push-notification
2
Initialize the client
Set up your OMX client and push notification service
typescript
1import { OMXClient } from '@omx-sdk/core';
2import { PushNotification } from '@omx-sdk/push-notification';
3
4const omx = new OMXClient({
5 clientId: 'your_client_id',
6 secretKey: 'your_secret_key'
7});
8
9const push = new PushNotification(omx);
3
Send your first notification
Send a simple push notification
typescript
1const result = await push.send({
2 to: 'device-token-or-user-id',
3 title: 'Welcome to Our App!',
4 body: 'Thanks for installing our app. Get started now!'
5});
6
7console.log('Notification sent:', result.messageId);
Core Features
Powerful capabilities for effective push notification campaigns.
Cross-Platform
Native support for iOS, Android, web browsers, and desktop applications.
Rich Notifications
Images, actions, deep links, and custom data payloads.
Device Management
Automatic device token management and registration handling.
User Targeting
Advanced segmentation and personalized delivery options.
Advanced Notification with Data
Send rich notifications with custom data and platform-specific options.
typescript
1const result = await push.send({
2 to: 'device-token-or-user-id',
3 title: 'Welcome to Our App!',
4 body: 'Thanks for installing our app. Get started now!',
5
6 // Additional data
7 data: {
8 screen: 'welcome',
9 userId: 'user_123'
10 },
11
12 // Platform-specific options
13 options: {
14 badge: 1,
15 sound: 'default',
16 priority: 'high'
17 }
18});
19
20console.log('Notification sent:', result.messageId);
iOS (APNs) Integration
Send rich notifications with iOS-specific features like badges, sounds, and attachments.
typescript
1await push.send({
2 to: 'ios-device-token',
3 title: 'New Message',
4 body: 'You have a new message waiting',
5
6 ios: {
7 badge: 5,
8 sound: 'notification.wav',
9 category: 'MESSAGE_CATEGORY',
10 mutableContent: true,
11 customData: {
12 attachmentUrl: 'https://example.com/image.jpg'
13 }
14 }
15});
Android (FCM) Integration
Utilize Android-specific features like notification channels, actions, and custom styling.
typescript
1await push.send({
2 to: 'android-device-token',
3 title: 'Order Update',
4 body: 'Your order has been shipped!',
5
6 android: {
7 icon: 'ic_notification',
8 color: '#FF5722',
9 channelId: 'order_updates',
10 priority: 'high',
11 actions: [
12 { action: 'track', title: 'Track Package' },
13 { action: 'dismiss', title: 'Dismiss' }
14 ]
15 }
16});
Permission Required: Push notifications require explicit user permission on all platforms. Always request permission before attempting to send notifications and handle permission denial gracefully.
Targeting and Segmentation
Send notifications to specific users, segments, or based on location and user properties.
typescript
1// Send to multiple users
2await push.sendToUsers({
3 userIds: ['user1', 'user2', 'user3'],
4 title: 'Flash Sale!',
5 body: '50% off everything - limited time only!'
6});
7
8// Send to user segment
9await push.sendToSegment({
10 segment: 'premium-users',
11 title: 'Exclusive Offer',
12 body: 'Special discount just for premium members'
13});
14
15// Send with conditions
16await push.send({
17 title: 'Local Weather Alert',
18 body: 'Rain expected in your area',
19 targeting: {
20 location: {
21 radius: 10000, // 10km
22 lat: 40.7128,
23 lng: -74.0060
24 },
25 userProperties: {
26 hasWeatherNotifications: true
27 }
28 }
29});
Next Steps
Now that you have push notifications set up, explore these advanced guides.