### Complete HTML Integration Example Source: https://rivium.co/cloud/rivium-push/docs/quick-start A full example showing how to initialize the SDK, set up callbacks, and trigger registration via a button click in a browser environment. ```html RiviumPush Web Demo

RiviumPush Web Push Demo

``` -------------------------------- ### Example Segment: VIP Users Source: https://rivium.co/cloud/rivium-push/docs/segments A configuration example for targeting VIP members based on custom metadata fields. ```json { "name": "VIP Members", "filters": [ { "field": "metadata.vip", "operator": "equals", "value": true }, { "field": "metadata.totalSpent", "operator": "greater_than", "value": 1000 } ] } ``` -------------------------------- ### Example Segment: Beta Testers Source: https://rivium.co/cloud/rivium-push/docs/segments A configuration example for targeting beta testers using the latest app version. ```json { "name": "Beta Testers", "filters": [ { "field": "metadata.betaTester", "operator": "equals", "value": true }, { "field": "appVersion", "operator": "starts_with", "value": "3." } ] } ``` -------------------------------- ### Install Rivium Push Node.js SDK Source: https://rivium.co/cloud/rivium-push/docs/nodejs Use npm to install the official Rivium Push package for Node.js. ```bash npm install @rivium/push-node ``` -------------------------------- ### Install SDK via NPM Source: https://rivium.co/cloud/rivium-push/docs/quick-start Use NPM or Yarn to add the @rivium/push-web package to your project. ```bash npm install @rivium/push-web # or yarn add @rivium/push-web ``` -------------------------------- ### Initialize and Configure Web SDK Source: https://rivium.co/cloud/rivium-push/docs/configuration Example of initializing the Web SDK and updating the log level at runtime. ```javascript import RiviumPushSDK, { RiviumPushLogLevel } from '@rivium/push-web'; const riviumPush = new RiviumPush({ // Required apiKey: 'rv_live_your_api_key', // Optional - defaults shown serviceWorkerPath: '/rivium-push-sw.js', autoRegisterServiceWorker: true, maxReconnectAttempts: 10, logLevel: RiviumPushLogLevel.DEBUG, }); // Change log level at runtime riviumPush.setLogLevel(RiviumPushLogLevel.ERROR); ``` -------------------------------- ### Example Segment: North American Android Users Source: https://rivium.co/cloud/rivium-push/docs/segments A configuration example for targeting Android users located in the US or Canada. ```json { "name": "North American Android", "filters": [ { "field": "platform", "operator": "equals", "value": "android" }, { "field": "country", "operator": "in", "value": ["US", "CA"] } ] } ``` -------------------------------- ### Install SDK via CDN (UMD) Source: https://rivium.co/cloud/rivium-push/docs/quick-start Include the UMD build directly in your HTML via a script tag. ```html ``` -------------------------------- ### POST /ab-tests/{testId}/start Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Starts an existing A/B test. ```APIDOC ## POST /ab-tests/{testId}/start ### Description Starts a previously created A/B test. ### Method POST ### Endpoint https://push-api.rivium.co/ab-tests/{testId}/start ``` -------------------------------- ### Initialize RiviumPush in Flutter Source: https://rivium.co/cloud/rivium-push/docs/configuration Example of initializing the RiviumPush SDK with required API key and platform-specific settings. ```dart await RiviumPush.init(RiviumPushConfig( // Required - only apiKey needed, server config is auto-fetched apiKey: 'rv_live_your_api_key', // iOS Options usePushKit: true, // Enable VoIP for reliable background delivery // Android Options showServiceNotification: true, serviceNotificationTitle: 'My App', serviceNotificationBody: 'Listening for notifications...', // Optional enableAnalytics: true, logLevel: RiviumPushLogLevel.debug, )); ``` -------------------------------- ### GET /devices Source: https://rivium.co/cloud/rivium-push/docs/devices Retrieves a list of all registered devices. ```APIDOC ## GET /devices ### Description Lists all registered devices. ### Method GET ### Endpoint https://push-api.rivium.co/devices ``` -------------------------------- ### GET /webhooks Source: https://rivium.co/cloud/rivium-push/docs/webhooks Retrieves a list of all configured webhooks. ```APIDOC ## GET /webhooks ### Description Retrieves a list of all webhooks associated with the account. ### Method GET ### Endpoint https://push-api.rivium.co/webhooks ``` -------------------------------- ### Install SDK via ES Module Source: https://rivium.co/cloud/rivium-push/docs/quick-start Import the ES module version of the SDK directly in your JavaScript. ```javascript import RiviumPush from 'https://unpkg.com/@rivium/push-web/dist/index.esm.js'; ``` -------------------------------- ### GET /templates Source: https://rivium.co/cloud/rivium-push/docs/templates Retrieves a list of all available notification templates. ```APIDOC ## GET /templates ### Description Retrieves a list of all notification templates defined in the system. ### Method GET ### Endpoint https://push-api.rivium.co/templates ``` -------------------------------- ### Start an A/B Test Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Activates a draft A/B test using the Node.js SDK or REST API. ```javascript await riviumPush.abTesting.start(testId); ``` ```bash curl -X POST "https://push-api.rivium.co/ab-tests/{testId}/start" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### A/B Test Creation Response Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Example JSON response returned after successfully creating an A/B test. ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "Welcome Message Test", "status": "draft", "hasControlGroup": true, "controlGroupPercentage": 10, "enableEarlyStopping": true, "variants": [ { "id": "var_control", "name": "Control", "isControlGroup": true, "trafficPercentage": 10 }, { "id": "var_1", "name": "Variant A - Friendly", "trafficPercentage": 45 }, { "id": "var_2", "name": "Variant B - Exciting", "trafficPercentage": 45 } ], "createdAt": "2026-01-21T10:00:00Z" } ``` -------------------------------- ### Install rivium-push-react-native package Source: https://rivium.co/cloud/rivium-push/docs/quick-start Use npm or yarn to add the Rivium Push SDK to your React Native project. ```bash npm install rivium-push-react-native # or yarn add rivium-push-react-native ``` -------------------------------- ### Initialize SDK with Environment Variables Source: https://rivium.co/cloud/rivium-push/docs/nodejs Initialize the RiviumPush client using credentials loaded from environment variables. ```javascript import { RiviumPush } from '@rivium-push/node'; const riviumPush = new RiviumPush({ apiKey: process.env.RIVIUM_PUSH_API_KEY, serverSecret: process.env.RIVIUM_PUSH_SECRET, }); ``` -------------------------------- ### React Native Complete Hook Example Source: https://rivium.co/cloud/rivium-push/docs/callbacks A custom hook that manages the full lifecycle of Rivium Push, including registration and event cleanup. ```typescript import { useEffect, useState } from 'react'; import RiviumPush from 'rivium-push-react-native'; export function useRiviumPush(userId: string) { const [connected, setConnected] = useState(false); const [deviceId, setDeviceId] = useState(null); useEffect(() => { const unsubMessage = RiviumPush.onMessage((msg) => { console.log('Message:', msg); }); const unsubConnection = RiviumPush.onConnectionState(setConnected); const unsubRegistered = RiviumPush.onRegistered(setDeviceId); RiviumPush.register({ userId }); return () => { unsubMessage(); unsubConnection(); unsubRegistered(); }; }, [userId]); return { connected, deviceId }; } ``` -------------------------------- ### Get Overview Statistics via REST API Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieve overall push notification statistics using a GET request to the analytics overview endpoint. ```bash curl -X GET "https://push-api.rivium.co/analytics/overview" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### Initialize RiviumPush SDK Source: https://rivium.co/cloud/rivium-push/docs/quick-start Initialize the SDK using your live API key. ```javascript import RiviumPush from 'rivium-push-react-native'; await RiviumPush.init({ apiKey: 'rv_live_your_api_key' }); ``` -------------------------------- ### Register and Manage Devices in Web Source: https://rivium.co/cloud/rivium-push/docs/devices Uses the rivium-push-web package to initialize the client and manage device registration, user IDs, and topic subscriptions. ```javascript import { RiviumPush } from 'rivium-push-web'; const riviumPush = new RiviumPush({ apiKey: 'your_api_key' }); await riviumPush.register({ userId: 'user_123', metadata: { plan: 'premium' }, }); await riviumPush.setUserId('user_123'); await riviumPush.subscribeToTopic('news'); await riviumPush.unsubscribeFromTopic('promotions'); await riviumPush.unregister(); ``` -------------------------------- ### Initialize RiviumPush Client Source: https://rivium.co/cloud/rivium-push/docs/nodejs Initialize the SDK by providing your API key and server secret from environment variables. ```javascript import { RiviumPush } from '@rivium-push/node'; const riviumPush = new RiviumPush({ apiKey: process.env.RIVIUM_PUSH_API_KEY, // rv_live_xxx serverSecret: process.env.RIVIUM_PUSH_SECRET, // rv_srv_xxx (required) }); ``` -------------------------------- ### GET /teams/members Source: https://rivium.co/cloud/rivium-push/docs/teams List all members currently in the team. ```APIDOC ## GET /teams/members ### Description Retrieve a list of all team members. ### Method GET ### Endpoint https://push-api.rivium.co/teams/members ### Response #### Success Response (200) - **members** (array) - List of team member objects #### Response Example { "members": [ { "id": "mem_1", "userId": "user_123", "email": "owner@example.com", "name": "John Owner", "role": "owner", "joinedAt": "2024-01-01T00:00:00Z" } ] } ``` -------------------------------- ### RiviumPushVoip.init Source: https://rivium.co/cloud/rivium-push/docs/voip Initializes the VoIP module with configuration settings including app name, timeout, and video support. ```APIDOC ## RiviumPushVoip.init(config) ### Description Initializes the VoIP service with the provided configuration. ### Parameters - **config** (Object) - Required - Configuration object containing appName (string), timeout (number), supportsVideo (boolean), and ringtoneName (string, iOS only). ``` -------------------------------- ### RiviumPush.init Source: https://rivium.co/cloud/rivium-push/docs/configuration Initializes the Rivium Push SDK with the required API key and platform-specific configuration options. ```APIDOC ## RiviumPush.init(RiviumPushConfig config) ### Description Initializes the SDK. The server configuration is automatically fetched using the provided API key. ### Parameters - **apiKey** (string) - Required - Your API key from the dashboard. - **usePushKit** (boolean) - Optional - iOS: Enable PushKit VoIP for reliable delivery (Default: true). - **showServiceNotification** (boolean) - Optional - Android: Show foreground service notification (Default: true). - **serviceNotificationTitle** (string) - Optional - Android: Foreground notification title (Default: "RiviumPush"). - **serviceNotificationBody** (string) - Optional - Android: Foreground notification body (Default: "Running..."). - **enableAnalytics** (boolean) - Optional - Send analytics events to server (Default: true). - **logLevel** (RiviumPushLogLevel) - Optional - Logging verbosity level (Default: debug). ### Example ```dart await RiviumPush.init(RiviumPushConfig( apiKey: 'rv_live_your_api_key', usePushKit: true, showServiceNotification: true, serviceNotificationTitle: 'My App', serviceNotificationBody: 'Listening for notifications...', enableAnalytics: true, logLevel: RiviumPushLogLevel.debug, )); ``` ``` -------------------------------- ### GET /scheduled Source: https://rivium.co/cloud/rivium-push/docs/scheduled Retrieve a list of scheduled push notifications. ```APIDOC ## GET /scheduled ### Description List all scheduled messages. ### Method GET ### Endpoint https://push-api.rivium.co/scheduled ### Response #### Success Response (200) - **id** (string) - The unique identifier of the scheduled message. - **title** (string) - The title of the message. - **body** (string) - The content of the message. - **targetType** (string) - The target type. - **scheduledAt** (string) - The scheduled delivery time. - **timezone** (string) - The timezone. - **status** (string) - The current status of the message. - **createdAt** (string) - The creation timestamp. #### Response Example [ { "id": "sch_abc123", "title": "Flash Sale!", "body": "50% off for 2 hours", "targetType": "broadcast", "scheduledAt": "2024-01-20T10:00:00Z", "timezone": "America/New_York", "status": "pending", "createdAt": "2024-01-15T12:00:00Z" } ] ``` -------------------------------- ### iOS Register & Listen Source: https://rivium.co/cloud/rivium-push/docs/quick-start Set up callbacks for messages, connection state, registration, and errors, then register the device. ```swift // Set up callbacks RiviumPush.shared.onMessage { message in print("Title: \(message.title ?? "")") print("Body: \(message.body ?? "")") print("Data: \(message.data ?? [:])") } RiviumPush.shared.onConnectionState { connected in print("Connected: \(connected)") } RiviumPush.shared.onRegistered { deviceId in print("Registered: \(deviceId)") } RiviumPush.shared.onDetailedError { error in print("Error [\(error.code.rawValue)]: \(error.message)") } // Register device with optional user ID RiviumPush.shared.register(userId: "user_123") ``` -------------------------------- ### Set Up SDK Callbacks Source: https://rivium.co/cloud/rivium-push/docs/quick-start Configure event listeners for messages, connection state changes, registration success, notification clicks, and errors. ```javascript // Message received (foreground) riviumPush.onMessage((message) => { console.log('Title:', message.title); console.log('Body:', message.body); console.log('Data:', message.data); }); // Connection state changes riviumPush.onConnectionState((state) => { console.log('Connection:', state); // 'connecting' | 'connected' | 'disconnected' | 'error' }); // Registration success riviumPush.onRegistered((deviceId) => { console.log('Device registered:', deviceId); }); // Notification clicked (from background) riviumPush.onNotificationClick((message, action) => { console.log('Notification clicked:', message.title); if (message.deepLink) { window.location.href = message.deepLink; } }); // Error handling with detailed error codes riviumPush.onDetailedError((error) => { console.error(`Error [${error.code}]: ${error.message}`, error.details); }); ``` -------------------------------- ### GET /analytics/recent Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieves the most recent push notification activity. ```APIDOC ## GET /analytics/recent ### Description Get the most recent push notification activity. ### Method GET ### Endpoint https://push-api.rivium.co/analytics/recent ### Parameters #### Query Parameters - **limit** (number) - Optional - Number of records to return ### Response #### Success Response (200) - **id** (string) - Message ID - **title** (string) - Message title - **body** (string) - Message body - **targetType** (string) - Target type - **status** (string) - Delivery status - **sentAt** (string) - Timestamp of sending #### Response Example [ { "id": "msg_abc123", "title": "New message", "body": "You have a new notification", "targetType": "user", "status": "delivered", "sentAt": "2024-01-15T10:30:00Z" } ] ``` -------------------------------- ### GET /receipts/device/{deviceId} Source: https://rivium.co/cloud/rivium-push/docs/receipts Retrieve receipt history for a specific device. ```APIDOC ## GET /receipts/device/{deviceId} ### Description Retrieve receipt history for a specific device. ### Method GET ### Endpoint https://push-api.rivium.co/receipts/device/{deviceId} ### Parameters #### Path Parameters - **deviceId** (string) - Required - The unique identifier of the device. #### Query Parameters - **limit** (integer) - Optional - Number of records to return. ### Response #### Success Response (200) - **id** (string) - Receipt ID - **messageId** (string) - Message ID - **status** (string) - Current status ### Response Example [ { "id": "rcpt_1", "messageId": "msg_abc123", "status": "opened" } ] ``` -------------------------------- ### Initialize RiviumPush SDK Source: https://rivium.co/cloud/rivium-push/docs/quick-start Create a new RiviumPush instance. The apiKey is required, while serverUrl and serviceWorkerPath have defaults. ```javascript import RiviumPush from '@rivium/push-web'; // Create RiviumPush instance - only apiKey is required // Server URL defaults to https://push-api.rivium.co const riviumPush = new RiviumPush({ apiKey: 'rv_live_your_api_key', serverUrl: 'https://push-api.rivium.co', // optional serviceWorkerPath: '/rivium-push-sw.js', // optional, default path }); ``` -------------------------------- ### GET /ab-tests/{testId} Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Retrieves the details and current results of an A/B test. ```APIDOC ## GET /ab-tests/{testId} ### Description Fetches the configuration and statistical performance results for an A/B test. ### Method GET ### Endpoint https://push-api.rivium.co/ab-tests/{testId} ### Response #### Success Response (200) - **id** (string) - Test ID - **status** (string) - Current status (e.g., 'running') - **statisticalResults** (object) - Statistical analysis data - **variants** (array) - Performance metrics per variant ``` -------------------------------- ### Initialize VoIP SDK Source: https://rivium.co/cloud/rivium-push/docs/voip Initialize the RiviumPushVoip instance in your Application.onCreate() and set the required callback interface. ```kotlin import co.rivium.push.voip.RiviumPushVoip import co.rivium.push.voip.VoipCallback import co.rivium.push.voip.VoipConfig import co.rivium.push.voip.CallData // Initialize in Application.onCreate() RiviumPushVoip.initialize( context = this, config = VoipConfig( appName = "MyApp", timeoutSeconds = 30, showMissedCallNotification = true ) ) // Set callback RiviumPushVoip.setCallback(object : VoipCallback { override fun onCallAccepted(callData: CallData) { Log.d("VoIP", "Call accepted: ${callData.callId}") // Start your call activity startCallActivity(callData) } override fun onCallDeclined(callData: CallData) { Log.d("VoIP", "Call declined: ${callData.callId}") } override fun onCallTimeout(callData: CallData) { Log.d("VoIP", "Call timeout: ${callData.callId}") } override fun onError(error: String) { Log.e("VoIP", "Error: $error") } }) ``` -------------------------------- ### Get Subscribed Topics in React Native Source: https://rivium.co/cloud/rivium-push/docs/topics Retrieve the list of subscribed topics. ```javascript const topics = await RiviumPush.getSubscribedTopics(); ``` -------------------------------- ### Get Subscribed Topics in Flutter Source: https://rivium.co/cloud/rivium-push/docs/topics Retrieve a list of currently subscribed topics. ```dart List topics = await RiviumPush.getSubscribedTopics(); // Output: [news, tech, movies] ``` -------------------------------- ### Web SDK Initialization Source: https://rivium.co/cloud/rivium-push/docs/configuration Initializes the Rivium Push Web SDK. ```APIDOC ## new RiviumPush(options) ### Description Initializes the Web SDK. Connection credentials and VAPID keys are automatically fetched from the server. ### Parameters - **apiKey** (string) - Required - Your API key from the dashboard. - **serviceWorkerPath** (string) - Optional - Path to service worker file (Default: /rivium-push-sw.js). - **autoRegisterServiceWorker** (boolean) - Optional - Auto-register service worker on init (Default: true). - **maxReconnectAttempts** (number) - Optional - Max reconnection attempts (Default: 10). - **logLevel** (RiviumPushLogLevel) - Optional - Logging verbosity (Default: DEBUG). ### Example ```javascript const riviumPush = new RiviumPush({ apiKey: 'rv_live_your_api_key', serviceWorkerPath: '/rivium-push-sw.js', autoRegisterServiceWorker: true, maxReconnectAttempts: 10, logLevel: RiviumPushLogLevel.DEBUG, }); ``` ``` -------------------------------- ### Get Recent Activity Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieve the most recent push notification activity logs. ```javascript const recent = await riviumPush.analytics.getRecent(10); ``` -------------------------------- ### Initialize and Register Devices in Flutter Source: https://rivium.co/cloud/rivium-push/docs/devices Initialize the SDK with an API key and register the device with optional user metadata. Includes methods for managing user IDs and topic subscriptions. ```dart import 'package:rivium_push/rivium_push.dart'; // Initialize RiviumPush (only apiKey required) await RiviumPush.init(RiviumPushConfig( apiKey: 'rv_live_your_api_key', )); // Register device with optional user ID and metadata await RiviumPush.register( userId: 'user_123', metadata: { 'plan': 'premium', 'language': 'en', }, ); // Update user ID after login await RiviumPush.setUserId('user_123'); // Clear user ID after logout await RiviumPush.clearUserId(); // Topics await RiviumPush.subscribeToTopic('news'); await RiviumPush.subscribeToTopic('promotions'); await RiviumPush.unsubscribeFromTopic('promotions'); // Unregister (e.g., user opts out) await RiviumPush.unregister(); ``` -------------------------------- ### Scheduled Message Response Format Source: https://rivium.co/cloud/rivium-push/docs/scheduled Example JSON response structure for a scheduled message. ```json [ { "id": "sch_abc123", "title": "Flash Sale!", "body": "50% off for 2 hours", "targetType": "broadcast", "scheduledAt": "2024-01-20T10:00:00Z", "timezone": "America/New_York", "status": "pending", "createdAt": "2024-01-15T12:00:00Z" } ] ``` -------------------------------- ### GET /analytics/hourly Source: https://rivium.co/cloud/rivium-push/docs/analytics Analyzes message distribution by hour of the day for a specified number of days. ```APIDOC ## GET /analytics/hourly ### Description Analyze message distribution by hour of day. ### Method GET ### Endpoint https://push-api.rivium.co/analytics/hourly ### Parameters #### Query Parameters - **days** (number) - Optional - Number of days to analyze ### Response #### Success Response (200) - **hour** (number) - Hour of the day (0-23) - **count** (number) - Number of messages #### Response Example [ { "hour": 0, "count": 120 } ] ``` -------------------------------- ### Configure Environment Variables Source: https://rivium.co/cloud/rivium-push/docs/nodejs Store your credentials in a .env file to keep them secure. ```bash # .env file RIVIUM_PUSH_API_KEY=rv_live_abc123def456... RIVIUM_PUSH_SECRET=rv_srv_xyz789... ``` -------------------------------- ### RiviumPushVoip.initialize Source: https://rivium.co/cloud/rivium-push/docs/voip Initializes the VoIP module within the application's lifecycle. ```APIDOC ## RiviumPushVoip.initialize ### Description Initializes the RiviumPushVoip service. This should be called in the Application.onCreate() method. ### Parameters - **context** (Context) - Required - The application context. - **config** (VoipConfig) - Required - Configuration object containing appName, timeoutSeconds, and showMissedCallNotification. ``` -------------------------------- ### GET /analytics/daily Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieves message statistics broken down by day for a specified number of days. ```APIDOC ## GET /analytics/daily ### Description Get message statistics broken down by day. ### Method GET ### Endpoint https://push-api.rivium.co/analytics/daily ### Parameters #### Query Parameters - **days** (number) - Optional - Number of days to retrieve statistics for ### Response #### Success Response (200) - **date** (string) - Date of statistics - **sent** (number) - Messages sent - **delivered** (number) - Messages delivered - **failed** (number) - Messages failed #### Response Example [ { "date": "2024-01-15", "sent": 520, "delivered": 510, "failed": 10 } ] ``` -------------------------------- ### Send A/B Test Notifications Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Triggers the distribution of notifications for a started A/B test. ```javascript const result = await riviumPush.abTesting.send(testId); ``` ```bash curl -X POST "https://push-api.rivium.co/ab-tests/{testId}/send" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### Initialize Rivium Push Analytics Source: https://rivium.co/cloud/rivium-push/docs/sdk-analytics Sets up the Rivium Push SDK and defines a basic analytics handler to log events. ```javascript import RiviumPushSDK, { RiviumPushAnalyticsEvent } from 'rivium-push-web'; const riviumPush = new RiviumPush({ apiKey: 'rv_live_your_api_key', }); // Set up analytics handler riviumPush.setAnalyticsHandler((event, properties) => { console.log('Analytics:', event, properties); // Send to your analytics service (Google Analytics, Mixpanel, etc.) gtag('event', `riviumPush_${event}`, properties); }); ``` -------------------------------- ### Initialize VoIP and Callbacks in Flutter Source: https://rivium.co/cloud/rivium-push/docs/voip Initialize the VoIP module with configuration and set up event listeners for call lifecycle events. ```dart import 'package:rivium_push/rivium_push.dart'; // Initialize VoIP with config await RiviumPushVoip.init( config: RiviumPushVoipConfig( appName: 'MyApp', timeout: 30, // Call timeout in seconds supportsVideo: true, // Enable video call support ringtoneName: null, // Custom ringtone (iOS only) ), ); // Set up callbacks RiviumPushVoip.onCallAccepted((call) { print('Call accepted: ${call.callId}'); print('Caller: ${call.callerName}'); print('Type: ${call.callType}'); // audio or video // Navigate to your call screen Navigator.push(context, MaterialPageRoute( builder: (_) => CallScreen(call: call), )); }); RiviumPushVoip.onCallDeclined((call) { print('Call declined: ${call.callId}'); // Notify your server that call was declined }); RiviumPushVoip.onCallTimeout((call) { print('Call timeout: ${call.callId}'); // Show missed call notification }); ``` -------------------------------- ### RiviumPush Constructor Source: https://rivium.co/cloud/rivium-push/docs/quick-start Initializes the RiviumPush SDK instance with your API key and optional configuration settings. ```APIDOC ## new RiviumPush(options) ### Description Creates a new instance of the RiviumPush SDK to manage push notifications. ### Parameters - **options** (object) - Required - **apiKey** (string) - Required: Your unique API key. - **serverUrl** (string) - Optional: Custom push server URL (defaults to https://push-api.rivium.co). - **serviceWorkerPath** (string) - Optional: Path to the service worker file (defaults to /rivium-push-sw.js). ``` -------------------------------- ### Webhook Receipt Event Source: https://rivium.co/cloud/rivium-push/docs/receipts Example payload for a real-time receipt update received via webhook. ```json { "event": "notification.opened", "timestamp": "2024-01-15T10:05:00Z", "data": { "messageId": "msg_abc123", "deviceId": "dev_xyz", "userId": "user_123", "platform": "ios" } } ``` -------------------------------- ### Retrieve VoIP Token Source: https://rivium.co/cloud/rivium-push/docs/voip Get the VoIP push token to send to your server for call notifications. ```swift // Get the VoIP push token (to send to your server) if let token = RiviumPushVoip.shared.getVoIPToken() { print("VoIP token: \(token)") // Send to your server for call notifications } ``` -------------------------------- ### Android Register & Listen Source: https://rivium.co/cloud/rivium-push/docs/quick-start Configure message, connection, registration, and error callbacks, then register the device. ```kotlin RiviumPush.onMessage { message -> // message.title, message.body, message.data } RiviumPush.onConnectionState { connected -> // true / false } RiviumPush.onRegistered { deviceId -> // Device registered } RiviumPush.onDetailedError { error -> // error.code, error.message } RiviumPush.register(userId = "user_123") ``` -------------------------------- ### GET /receipts/app/{appId}/stats Source: https://rivium.co/cloud/rivium-push/docs/receipts Aggregate statistics across an app for a specific date range. ```APIDOC ## GET /receipts/app/{appId}/stats ### Description Aggregate stats across an app for a date range. ### Method GET ### Endpoint https://push-api.rivium.co/receipts/app/{appId}/stats ### Parameters #### Path Parameters - **appId** (string) - Required - The unique identifier of the app. #### Query Parameters - **startDate** (string) - Required - Start date (YYYY-MM-DD) - **endDate** (string) - Required - End date (YYYY-MM-DD) ### Response #### Success Response (200) - **totalMessages** (number) - Total messages sent - **deliveryRate** (number) - Delivery rate ### Response Example { "totalMessages": 150, "deliveryRate": 96.67 } ``` -------------------------------- ### Handle Initial Call on Launch Source: https://rivium.co/cloud/rivium-push/docs/voip Check for an initial call when the app launches and navigate to the call screen if present. ```swift if let initialCall = RiviumPushVoip.shared.getInitialCall() { showCallScreen(initialCall) RiviumPushVoip.shared.clearInitialCall() } ``` -------------------------------- ### GET /receipts/message/{messageId}/stats Source: https://rivium.co/cloud/rivium-push/docs/receipts Aggregate delivery, open, and click rates for a single message. ```APIDOC ## GET /receipts/message/{messageId}/stats ### Description Aggregate delivery, open, and click rates for a single message. ### Method GET ### Endpoint https://push-api.rivium.co/receipts/message/{messageId}/stats ### Parameters #### Path Parameters - **messageId** (string) - Required - The unique identifier of the message. ### Response #### Success Response (200) - **total** (number) - Total messages - **sent** (number) - Messages sent - **delivered** (number) - Messages delivered - **opened** (number) - Messages opened - **clicked** (number) - Messages clicked - **failed** (number) - Messages failed - **deliveryRate** (number) - Delivery rate percentage - **openRate** (number) - Open rate percentage - **clickRate** (number) - Click rate percentage ### Response Example { "total": 1000, "sent": 980, "delivered": 950, "opened": 450, "clicked": 120, "failed": 20, "deliveryRate": 96.94, "openRate": 47.37, "clickRate": 12.63 } ``` -------------------------------- ### Get Subscribed Topics on Web Source: https://rivium.co/cloud/rivium-push/docs/topics Retrieve the list of subscribed topics using the riviumPush instance. ```javascript const topics = await riviumPush.getSubscribedTopics(); ``` -------------------------------- ### List Scheduled Messages with REST API Source: https://rivium.co/cloud/rivium-push/docs/scheduled Retrieve scheduled messages via a GET request. ```bash curl -X GET "https://push-api.rivium.co/scheduled" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### Create a Webhook with Node.js SDK Source: https://rivium.co/cloud/rivium-push/docs/webhooks Use the RiviumPush SDK to create a new webhook by specifying a name, URL, and list of events. ```javascript import { RiviumPush } from '@rivium-push/node'; const riviumPush = new RiviumPush({ apiKey: 'rv_live_your_api_key', serverSecret: 'rv_srv_your_server_secret', }); const webhook = await riviumPush.webhooks.create({ name: 'Analytics Webhook', url: 'https://your-server.com/webhooks/rivium-push', events: ['message.sent', 'message.delivered', 'message.failed'], }); console.log('Webhook secret:', webhook.secret); ``` -------------------------------- ### GET /analytics/message-types Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieves the distribution of messages by send type (user, device, topic, broadcast). ```APIDOC ## GET /analytics/message-types ### Description See how messages are distributed by send type (user / device / topic / broadcast). ### Method GET ### Endpoint https://push-api.rivium.co/analytics/message-types ### Response #### Success Response (200) - **type** (string) - Send type - **count** (number) - Number of messages - **percentage** (number) - Percentage of total messages #### Response Example [ { "type": "user", "count": 8500, "percentage": 55.1 } ] ``` -------------------------------- ### Register device and listen for messages Source: https://rivium.co/cloud/rivium-push/docs/quick-start Set up a message listener and register the device with a user ID. Remember to call the unsubscribe function when the component unmounts. ```javascript // Listen for messages const unsubscribe = RiviumPush.onMessage((message) => { console.log('Title:', message.title); console.log('Body:', message.body); console.log('Data:', message.data); }); // Register device await RiviumPush.register({ userId: 'user_123' }); // Don't forget to unsubscribe when component unmounts // unsubscribe(); ``` -------------------------------- ### Android Initialize SDK Source: https://rivium.co/cloud/rivium-push/docs/quick-start Initialize the SDK in your Application class or MainActivity. ```kotlin import co.rivium.push.sdk.RiviumPush import co.rivium.push.sdk.RiviumPushConfig // In your Application class or MainActivity RiviumPush.init( applicationContext, RiviumPushConfig(apiKey = "rv_live_your_api_key"), ) ``` -------------------------------- ### Get Hourly Distribution Source: https://rivium.co/cloud/rivium-push/docs/analytics Analyze message distribution by hour of the day for the specified number of days. ```javascript const hourly = await riviumPush.analytics.getHourly(7); ``` -------------------------------- ### Android (Kotlin): Setting Up Analytics Handler Source: https://rivium.co/cloud/rivium-push/docs/sdk-analytics Configure the analytics handler using RiviumPushAnalyticsCallback to log events and forward them to Firebase. ```kotlin import co.rivium.push.sdk.RiviumPush import co.rivium.push.sdk.RiviumPushAnalyticsCallback import co.rivium.push.sdk.RiviumPushAnalyticsEvent RiviumPush.setAnalyticsHandler(RiviumPushAnalyticsCallback { event, properties -> Log.d("RiviumPush", "Event: $event") Log.d("RiviumPush", "Properties: $properties") // Send to your analytics service val params = Bundle().apply { properties.forEach { (k, v) -> putString(k, v?.toString()) } } FirebaseAnalytics.getInstance(context).logEvent("riviumPush_$event", params) }) ``` -------------------------------- ### Get Daily Statistics Source: https://rivium.co/cloud/rivium-push/docs/analytics Retrieve message statistics broken down by day for the specified number of days. ```javascript const daily = await riviumPush.analytics.getDaily(30); ``` -------------------------------- ### Create an A/B Test with Node.js SDK Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Initializes the RiviumPush client and creates a new A/B test with specified variants and statistical parameters. ```javascript import { RiviumPush } from '@rivium-push/node'; const riviumPush = new RiviumPush({ apiKey: 'rv_live_your_api_key', serverSecret: 'rv_srv_your_server_secret', }); const test = await riviumPush.abTesting.create({ appId: 'your_project_id', name: 'Welcome Message Test', description: 'Testing different welcome messages', targetType: 'all', targetPercentage: 100, hasControlGroup: true, controlGroupPercentage: 10, winningMetric: 'click_rate', testDurationHours: 72, autoSelectWinner: true, enableEarlyStopping: true, significanceThreshold: 0.95, minimumSampleSize: 100, variants: [ { name: 'Variant A - Friendly', title: 'Welcome!', body: 'Thanks for joining us.', trafficPercentage: 45 }, { name: 'Variant B - Exciting', title: 'Welcome!', body: 'You are going to love this!', trafficPercentage: 45 }, ], }); ``` -------------------------------- ### List All Devices Source: https://rivium.co/cloud/rivium-push/docs/devices Retrieves a list of all registered devices. ```bash curl -X GET "https://push-api.rivium.co/devices" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### iOS Initialize SDK Source: https://rivium.co/cloud/rivium-push/docs/quick-start Initialize the SDK in your AppDelegate or App initialization logic. ```swift import RiviumPushSDK // In AppDelegate or App init RiviumPush.shared.initialize( config: RiviumPushConfig(apiKey: "rv_live_your_api_key") ) ``` -------------------------------- ### GET /receipts/message/{messageId}/actions Source: https://rivium.co/cloud/rivium-push/docs/receipts Retrieve statistics on which action buttons users clicked most for a specific message. ```APIDOC ## GET /receipts/message/{messageId}/actions ### Description See which action buttons users clicked most for a specific message. ### Method GET ### Endpoint https://push-api.rivium.co/receipts/message/{messageId}/actions ### Parameters #### Path Parameters - **messageId** (string) - Required - The unique identifier of the message. ### Response #### Success Response (200) - **actionId** (string) - The ID of the action button - **count** (number) - Number of clicks ### Response Example [ { "actionId": "shop_now", "count": 85 }, { "actionId": "remind_later", "count": 35 } ] ``` -------------------------------- ### riviumPush.devices.list Source: https://rivium.co/cloud/rivium-push/docs/nodejs Lists all devices registered in the system. ```APIDOC ## riviumPush.devices.list ### Description Retrieves a list of all devices associated with the project. ``` -------------------------------- ### GET /receipts/message/{messageId} Source: https://rivium.co/cloud/rivium-push/docs/receipts Retrieve per-device receipt for a single message, including timestamps for lifecycle stages. ```APIDOC ## GET /receipts/message/{messageId} ### Description Retrieve per-device receipt for a single message, including timestamps for lifecycle stages and action buttons tapped. ### Method GET ### Endpoint https://push-api.rivium.co/receipts/message/{messageId} ### Parameters #### Path Parameters - **messageId** (string) - Required - The unique identifier of the message. ### Response #### Success Response (200) - **receipts** (array) - List of individual device receipts ### Response Example { "receipts": [ { "id": "rcpt_1", "messageId": "msg_abc123", "deviceId": "dev_xyz", "platform": "ios", "status": "clicked", "sentAt": "2024-01-15T10:00:00Z", "deliveredAt": "2024-01-15T10:00:01Z", "openedAt": "2024-01-15T10:05:00Z", "clickedAt": "2024-01-15T10:05:30Z", "actionId": "shop_now" } ] } ``` -------------------------------- ### Get App-wide Stats API Source: https://rivium.co/cloud/rivium-push/docs/receipts Aggregate statistics across an entire application for a specified date range. ```bash curl -X GET "https://push-api.rivium.co/receipts/app/app_123/stats?startDate=2024-01-01&endDate=2024-01-31" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` ```json { "totalMessages": 150, "totalRecipients": 45000, "delivered": 43500, "opened": 18000, "clicked": 4500, "failed": 1500, "deliveryRate": 96.67, "openRate": 41.38, "clickRate": 10.34 } ``` -------------------------------- ### Initialize VoIP on iOS Source: https://rivium.co/cloud/rivium-push/docs/voip Initialize the RiviumPushVoip instance in your AppDelegate with the required configuration. ```swift import RiviumPushVoip // In AppDelegate.didFinishLaunchingWithOptions let config = VoipConfig( appName: "MyApp", callTimeout: 30, supportsVideo: true, ringtoneName: "ringtone.caf", iconTemplateName: "CallIcon" ) RiviumPushVoip.shared.initialize(config: config) RiviumPushVoip.shared.delegate = self RiviumPushVoip.shared.registerForVoIPPushes() ``` -------------------------------- ### Get Action Stats API Source: https://rivium.co/cloud/rivium-push/docs/receipts Retrieve statistics on which action buttons users clicked most for a specific message. ```bash curl -X GET "https://push-api.rivium.co/receipts/message/msg_abc123/actions" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` ```json [ { "actionId": "shop_now", "count": 85 }, { "actionId": "remind_later", "count": 35 } ] ``` -------------------------------- ### POST /segments/preview Source: https://rivium.co/cloud/rivium-push/docs/segments Previews the device count and sample devices for a set of filters. ```APIDOC ## POST /segments/preview ### Description Get the count and preview of devices matching your filters before saving a segment. ### Method POST ### Endpoint https://push-api.rivium.co/segments/preview ### Request Body - **filters** (array) - Required - List of filter objects ### Request Example { "filters": [ { "field": "platform", "operator": "equals", "value": "ios" } ] } ### Response #### Success Response (200) - **count** (number) - Total matching devices - **preview** (array) - List of sample devices ``` -------------------------------- ### Get A/B Test Results Source: https://rivium.co/cloud/rivium-push/docs/ab-testing Retrieves the current status and statistical performance data for an A/B test. ```javascript const test = await riviumPush.abTesting.get(testId); const results = await riviumPush.abTesting.getResults(testId); ``` ```bash curl -X GET "https://push-api.rivium.co/ab-tests/{testId}" \ -H "x-api-key: rv_live_your_api_key" \ -H "x-server-secret: rv_srv_your_server_secret" ``` -------------------------------- ### Initialize VoIP and Callbacks in React Native Source: https://rivium.co/cloud/rivium-push/docs/voip Initialize the VoIP module and manage event listeners with cleanup in React Native. ```typescript import { RiviumPushVoip, VoipCall } from 'rivium-push-react-native'; await RiviumPushVoip.init({ appName: 'MyApp', timeout: 30, supportsVideo: true, }); const unsubAccepted = RiviumPushVoip.onCallAccepted((call: VoipCall) => { navigation.navigate('CallScreen', { call }); }); const unsubDeclined = RiviumPushVoip.onCallDeclined((call: VoipCall) => { // Handle decline }); const unsubTimeout = RiviumPushVoip.onCallTimeout((call: VoipCall) => { // Handle timeout }); // Clean up useEffect(() => { return () => { unsubAccepted(); unsubDeclined(); unsubTimeout(); }; }, []); ```