### Install Go SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the Go SDK using the go get command. This command fetches and installs the NotificationAPI SDK for Go. ```bash go get github.com/notificationapi-com/notificationapi-go-server-sdk ``` -------------------------------- ### Example AppDelegate Setup Source: https://github.com/pingram-io/docs/blob/main/docs/reference/ios-sdk.md Extend NotificationApiAppDelegate and configure the SDK with your credentials. Request notification authorization from the user as early as possible. ```swift class AppDelegate: NotificationApiAppDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { NotificationApi.shared.configure(withCredentials: NotificationApiCredentials(clientId: "YOUR_CLIENT_ID", userId: "YOUR_USER_ID")) NotificationApi.shared.requestAuthorization { granted, _ in print("Is authorized?: \(granted)") } return true } } ``` -------------------------------- ### AppDelegate Setup Source: https://github.com/pingram-io/docs/blob/main/docs/reference/ios-sdk.md Example of how to set up your AppDelegate to use the NotificationAPI SDK, including configuration and authorization. ```APIDOC ## AppDelegate Setup ### Description This code snippet demonstrates how to configure the NotificationAPI SDK within your application's AppDelegate and request user authorization for push notifications. ### Usage Extend `NotificationApiAppDelegate` and implement the `application(_:didFinishLaunchingWithOptions:)` method. ### Code Example ```swift class AppDelegate: NotificationApiAppDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { NotificationApi.shared.configure(withCredentials: NotificationApiCredentials(clientId: "YOUR_CLIENT_ID", userId: "YOUR_USER_ID")) NotificationApi.shared.requestAuthorization { granted, _ in print("Is authorized?: \(granted)") } return true } } ``` ``` -------------------------------- ### Install Dependencies Source: https://github.com/pingram-io/docs/blob/main/README.md Navigate into the project directory and install necessary dependencies using npm. ```bash cd docs npm install --force ``` -------------------------------- ### Install NPM Package Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/display-inapp-notifications.md Install the notificationapi-js-client-sdk package using npm. ```bash npm install notificationapi-js-client-sdk ``` -------------------------------- ### Install Yarn Package Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/display-inapp-notifications.md Install the notificationapi-js-client-sdk package using yarn. ```bash yarn add notificationapi-js-client-sdk ``` -------------------------------- ### Install Laravel Server SDK (with warnings) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Install the Laravel Server SDK using Composer, including warnings. ```bash composer require notificationapi/notificationapi-laravel-server-sdk:@dev -W ``` -------------------------------- ### Install Vanilla JS SDK Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Install the NotificationAPI JavaScript client SDK using npm, yarn, or pnpm. ```shell npm install notificationapi-js-client-sdk # yarn add notificationapi-js-client-sdk # pnpm add notificationapi-js-client-sdk ``` -------------------------------- ### Install Core SDK with npm Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Install the NotificationAPI core SDK using npm. ```shell npm install @notificationapi/core ``` -------------------------------- ### Start Development Server Source: https://github.com/pingram-io/docs/blob/main/README.md Launch the local development server to preview your changes in real-time. ```bash npm run start ``` -------------------------------- ### Install PNPM Package Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/display-inapp-notifications.md Install the notificationapi-js-client-sdk package using pnpm. ```bash pnpm add notificationapi-js-client-sdk ``` -------------------------------- ### Install PHP SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the PHP SDK using Composer. This command integrates the NotificationAPI SDK into your PHP project. ```bash composer require notificationapi/notificationapi-php-server-sdk ``` -------------------------------- ### Install Core SDK with Yarn Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Install the NotificationAPI core SDK using Yarn. ```shell yarn add @notificationapi/core ``` -------------------------------- ### Install Python SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the Python SDK using pip. This command adds the NotificationAPI SDK to your Python environment. ```bash pip install notificationapi_python_server_sdk ``` -------------------------------- ### Install React SDK Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Install the NotificationAPI React SDK using npm, yarn, or pnpm. Ensure legacy peer dependencies are handled if necessary. ```shell npm install @notificationapi/react --legacy-peer-deps # or # yarn add @notificationapi/react # or # pnpm add @notificationapi/react ``` -------------------------------- ### Install Node.js SDK with npm Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the Node.js SDK using npm. This is the first step to integrate NotificationAPI into your Node.js application. ```bash npm install notificationapi-node-server-sdk ``` -------------------------------- ### Install C# SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the C# SDK using the dotnet CLI. This command adds the NotificationAPI package to your .NET project. ```csharp dotnet add package NotificationAPI --version 0.5.0 ``` -------------------------------- ### Install Laravel Server SDK (stable stability) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Install the Laravel Server SDK using Composer, maintaining stable stability. ```bash composer require notificationapi/notificationapi-php-server-sdk:@dev ``` -------------------------------- ### Install Node.js SDK with yarn Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the Node.js SDK using yarn. This is an alternative package manager for Node.js applications. ```bash yarn add notificationapi-node-server-sdk ``` -------------------------------- ### Install Laravel Server SDK (dev stability) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Install the Laravel Server SDK using Composer, setting minimum stability to 'dev'. ```bash composer require notificationapi/notificationapi-laravel-server-sdk:@dev ``` -------------------------------- ### Install Node.js SDK with pnpm Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Install the Node.js SDK using pnpm. This is another package manager for Node.js applications. ```bash pnpm add notificationapi-node-server-sdk ``` -------------------------------- ### Example AND/OR Query Source: https://github.com/pingram-io/docs/blob/main/docs/features/logs.md Demonstrates how to combine multiple queries using AND (&&), OR (||), and parentheses for complex filtering of log data. This allows for sophisticated searches based on multiple criteria. ```javascript ($.request.type='new-user' && $.request.to.number='+19999999999') || $.request.parameters.firstName="Jane" ``` -------------------------------- ### Install React SDK using npm Source: https://github.com/pingram-io/docs/blob/main/docs/reference/react-sdk.md Install the NotificationAPI React package using npm. Consider using --legacy-peer-deps if you encounter React version conflicts. ```shell npm install @notificationapi/react --legacy-peer-deps ``` -------------------------------- ### Rust Environment Variables Setup Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Configure your .env file in the project root with your NotificationAPI client ID and secret. ```env CLIENT_ID=your_client_id CLIENT_SECRET=your_client_secret ``` -------------------------------- ### Install React SDK using pnpm Source: https://github.com/pingram-io/docs/blob/main/docs/reference/react-sdk.md Install the NotificationAPI React package using pnpm. Consider using --legacy-peer-deps if you encounter React version conflicts. ```shell pnpm add @notificationapi/react ``` -------------------------------- ### Install React SDK using yarn Source: https://github.com/pingram-io/docs/blob/main/docs/reference/react-sdk.md Install the NotificationAPI React package using yarn. Consider using --legacy-peer-deps if you encounter React version conflicts. ```shell yarn add @notificationapi/react ``` -------------------------------- ### Basic NotificationAPIProvider Setup Source: https://github.com/pingram-io/docs/blob/main/docs/reference/react-sdk.md Set up the NotificationAPIProvider in your top-level component. Provide your clientId and userId to enable notification services. ```jsx import { NotificationAPIProvider } from '@notificationapi/react'; ; ``` -------------------------------- ### Example of attacker impersonation Source: https://github.com/pingram-io/docs/blob/main/docs/guides/secure-mode.md This example demonstrates how an attacker might attempt to impersonate another user by initializing a third-party library with a different user ID. ```javascript someLibrary.initialize({ userId: 'another-user-id' }); ``` -------------------------------- ### Initialize Python SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the NotificationAPI Python SDK with your client ID and client secret. This setup is necessary for subsequent operations. ```python notificationapi.init("CLIENT_ID", "CLIENT_SECRET") ``` -------------------------------- ### CSS Styling Example Source: https://github.com/pingram-io/docs/blob/main/docs/components/inapp.md Demonstrates how to override default CSS styles for the in-app notifications widget to match custom branding. Inspect elements to find correct classes. ```css /* Change the icon */ .notificationapi-button .icon-bell-o:before { content: url('apple-whole-solid.svg'); } /* Change the notification text size */ .notificationapi-notification-title { font-size: 18px !important; } ``` -------------------------------- ### Prepare Notification Payload in Rust Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Set up the necessary structs and async main function to send a notification using Rust. This example includes environment variable loading for API credentials. ```rust use reqwest::Client; use serde::Serialize; use std::env; use dotenv::dotenv; #[derive(Serialize)] struct NotificationPayload<'a> { #[serde(rename = "type")] notification_type: &'a str, to: User, #[serde(rename = "parameters")] parameters: Parameters<'a>, } #[derive(Serialize)] struct User { id: String, email: String, number: String, } #[derive(Serialize)] struct Parameters<'a> { item: &'a str, address: &'a str, orderId: &'a str, } #[tokio::main] async fn main() -> Result<(), Box> { // Initialize environment variables dotenv().ok(); let client_id = env::var("CLIENT_ID").expect("CLIENT_ID not set in .env file"); let client_secret = env::var("CLIENT_SECRET").expect("CLIENT_SECRET not set in .env file"); // Create HTTP client let client = Client::new(); // Prepare notification payload ``` -------------------------------- ### Popup Mode Example Source: https://github.com/pingram-io/docs/blob/main/docs/components/inapp.md Displays the in-app notifications widget with a bell icon that opens a popup. This is the default behavior. ```javascript showInApp() ``` -------------------------------- ### Identify User with Basic Data (C#) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md A C# example for identifying a user with their ID, email, and telephone number. This is a simpler identification method. ```csharp var userId = "spongebob.squarepants"; await notificationApi.Identify(userId, new IdentifyUserData() { Email = "spongebob.squarepants", TelephoneNumber = "+15005550006" }); ``` -------------------------------- ### Show User Preferences with JS SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/manage-preferences.md Initialize the NotificationAPI client and display the user preferences modal using the JavaScript SDK. Ensure you have installed the 'notificationapi-js-client-sdk' package. ```javascript // npm install notificationapi-js-client-sdk import NotificationAPIClient from 'notificationapi-js-client-sdk'; const notificationapi = new NotificationAPIClient({ clientId: 'CLIENT_ID', userId: 'USER_ID' }); notificationapi.showUserPreferences(); ``` -------------------------------- ### Remix In-App Notification Setup Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/display-inapp-notifications.md Integrates the NotificationAPI SDK into a Remix application. Includes configuration for server dependencies, CSS imports, and client-side widget rendering. ```js serverDependenciesToBundle: ['notificationapi-js-client-sdk']; ``` ```jsx import NotificationAPICSS from 'notificationapi-js-client-sdk/dist/styles.css'; export const links: LinksFunction = () => { return [ { rel: 'stylesheet', href: NotificationAPICSS } // and the other links ... ]; }; ``` ```jsx import NotificationAPIClient from 'notificationapi-js-client-sdk'; import { useEffect } from 'react'; export default function Index() { useEffect(() => { const notificationapi = new NotificationAPIClient({ clientId: 'CLIENT_ID', userId: 'USER_ID' }); notificationapi.showInApp({ root: 'bell-container' }); }, []); return (
); } ``` -------------------------------- ### Import Python SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Import the notificationapi module from the installed Python SDK package. This makes the SDK functions available for use. ```python from notificationapi_python_server_sdk import notificationapi ``` -------------------------------- ### Angular In-App Notification Setup Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/display-inapp-notifications.md Instructions for integrating the NotificationAPI SDK into an Angular application. Includes adding CSS to global styles and using the SDK in a component's `ngOnInit` method. ```js @import 'node_modules/notificationapi-js-client-sdk/dist/styles.css' ``` ```jsx import NotificationAPI from 'notificationapi-js-client-sdk'; import {PopupPosition} from 'notificationapi-js-client-sdk/lib/interfaces'; ngOnInit() { const notificationapi = new NotificationAPI({ userId: "USERS_ID", clientId: "CLIENT_ID", }); notificationapi.showInApp({ root: 'bell-container', // root element containing the button popupPosition: PopupPosition.BottomLeft }); } // This goes inside the template
``` -------------------------------- ### Rust Notification Sending Example Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md This snippet demonstrates how to initialize the NotificationAPI client, construct a notification payload, and send it asynchronously. It requires `CLIENT_ID` and `CLIENT_SECRET` environment variables to be set. ```rust use reqwest::Client; use serde::Serialize; use std::env; use dotenv::dotenv; #[derive(Serialize)] struct NotificationPayload<'a> { #[serde(rename = "type")] notification_type: &'a str, #[serde(rename = "to")] to: User, #[serde(rename = "parameters")] parameters: Parameters<'a>, } #[derive(Serialize)] struct User { id: String, email: String, number: String, } #[derive(Serialize)] struct Parameters<'a> { item: &'a str, address: &'a str, orderId: &'a str, } #[tokio::main] async fn main() -> Result<(), Box> { // Initialize environment variables dotenv().ok(); let client_id = env::var("CLIENT_ID").expect("CLIENT_ID not set in .env file"); let client_secret = env::var("CLIENT_SECRET").expect("CLIENT_SECRET not set in .env file"); // Create HTTP client let client = Client::new(); // Prepare notification payload let payload = NotificationPayload { notification_type: "order_tracking", to: User { id: "spongebob.squarepants".to_string(), email: "spongebob@squarepants.com".to_string(), number: "+15005550006".to_string() }, parameters: Parameters { item: "Krabby Patty Burger", address: "124 Conch Street", orderId: "1234567890", }, }; // Send notification let response = client .post("https://api.notificationapi.com/{client_id}/sender") .basic_auth(client_id, Some(client_secret)) .json(&payload) .send() .await?; // Check the response status if response.status().is_success() { println!("Notification sent successfully!"); } else { println!("Failed to send notification: {:?}", response.text().await?); } Ok(()) } ``` -------------------------------- ### Identify User with Push and Web Push Tokens (Ruby) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md A Ruby example for identifying a user, specifying their contact details and token information for various notification channels. ```ruby user_id = "spongebob.squarepants" user_data = { email: "spongebob@squarepants.com", number: "+15005550006", pushTokens: [ { type: PushProviders::FCM, # Assuming PushProviders::FCM is defined token: "samplePushToken", device: { app_id: "com.example.app", ad_id: "1234567890", device_id: "1234567890", platform: "android", manufacturer: "Samsung", model: "SM-G930F" } } ], webPushTokens: [ { sub: { endpoint: "https://fcm.googleapis.com/fcm/send/fCs_4iba0Ao:APA91bGFdaU7I3****JMH_KeZwk1Xi", keys: { p256dh: "zP2xFu3hMc2vNH5E2nuKkyjpZydvCk9llRUY2kP4****9aSlKcoadSV2UbvMRQ", auth: "CXEFun************tYe8g" } } } ] } notification_api.identify_user(user_id, user_data) ``` -------------------------------- ### Initialize Go SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Go SDK with your client ID, client secret, and base URL. Ensure you have imported the necessary package. ```go import ( notificationapi "github.com/notificationapi-com/notificationapi-go-server-sdk" ) notificationapi.Init("CLIENT_ID", "CLIENT_SECRET", "base_url") ``` -------------------------------- ### Initialize PHP SDK for EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the PHP SDK specifying the EU region using a predefined constant. ```php use NotificationAPI\NotificationAPI; notificationapi.init("CLIENT_ID", "CLIENT_SECRET", notificationapi.EU_REGION) ``` -------------------------------- ### Initialize Java SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Java SDK with your client ID, client secret, and the base URL for the desired region. ```java import com.notificationapi.NotificationApi; NotificationApi api = new NotificationApi("CLIENT_ID", "CLIENT_SECRET", "https://api.notificationapi.com"); ``` -------------------------------- ### Initialize PHP Server SDK with EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Instantiate the PHP NotificationAPI client, specifying the client ID, client secret, and the EU region base URL. ```php use NotificationAPI\NotificationAPI; $notificationapi = new NotificationAPI("CLIENT_ID", "CLIENT_SECRET", "https://api.eu.notificationapi.com"); ``` -------------------------------- ### Initialize Java SDK for EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Java SDK for the EU region by specifying the EU base URL. ```java // For EU region NotificationApi api = new NotificationApi("CLIENT_ID", "CLIENT_SECRET", "https://api.eu.notificationapi.com"); ``` -------------------------------- ### Example Webhook Payload for Email Open Event Source: https://github.com/pingram-io/docs/blob/main/docs/features/events-webhook.md This is an example of the JSON payload structure sent for an email open event. It includes details about the event type, tracking ID, notification ID, channel, and user ID. ```javascript { "eventType": "OPEN", "trackingId": "abc123", "notificationId": "welcome-email", "channel": "EMAIL", "userId": "user-123" } ``` -------------------------------- ### NotificationAPIClientSDK.init Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Initializes the client with your application's credentials and sets up callbacks for real-time events. ```APIDOC ## NotificationAPIClientSDK.init ### Description Initializes the client with your application's credentials and sets up callbacks for real-time events. ### Method `NotificationAPIClientSDK.init(options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **clientId** (string) - Required - Your application's client ID. - **userId** (string) - Required - The ID of the current user. - **hashedUserId** (string) - Optional - Required if using secure mode. - **onNewInAppNotifications** (function) - Optional - Callback function for new in-app notifications. ### Request Example ```javascript import { NotificationAPIClientSDK } from '@notificationapi/core'; const client = NotificationAPIClientSDK.init({ clientId: 'CLIENT_ID', userId: 'USER_ID', onNewInAppNotifications: (notifications) => { console.log('New notifications arrived:', notifications); } }); ``` ### Response #### Success Response (200) Returns an initialized client instance. #### Response Example ```json { "client": "[Client Instance]" } ``` ``` -------------------------------- ### Clone Repository Source: https://github.com/pingram-io/docs/blob/main/README.md Clone the project repository to your local machine to begin development. ```bash git clone https://github.com/notificationapi-com/docs.git ``` -------------------------------- ### Schedule a Notification (Python) Source: https://github.com/pingram-io/docs/blob/main/docs/features/scheduling.md Schedule a notification for a future time using Python. This example requires an asynchronous function and the asyncio library. ```python import asyncio async def send_notification(): await notificationapi.send( { "type": "order_tracking", "to": { "id": "spongebob.squarepants", "email": "spongebob@squarepants.com", "number": "+15005550006", }, "parameters": { "item": "Krabby Patty Burger", "address": "124 Conch Street", "orderId": "1234567890" }, "schedule": "2024-02-20T14:38:03.509Z" } ) # Run the async function asyncio.run(send_notification()) ``` -------------------------------- ### Initialize C# SDK for EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the C# SDK for the EU region by providing the specific base URL. ```csharp using NotificationApi.Server; var notificationApi = new NotificationApiServer("CLIENT_ID", "CLIENT_SECRET", false, "https://api.eu.notificationapi.com"); ``` -------------------------------- ### Get User Preferences Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Retrieve the user's complete notification preferences object, including available options for each notification type. ```javascript const prefs = await client.rest.getPreferences(); ``` -------------------------------- ### Initialize C# SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the C# SDK with your client ID, client secret, and secure mode setting. The baseURL can be optionally provided for non-US regions. ```csharp using NotificationApi.Server; using NotificationApi.Server.Models; var notificationApi = new NotificationApiServer("CLIENT_ID", "CLIENT_SECRET", false); ``` -------------------------------- ### Get User Notification Preferences Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-client.md Retrieves the current notification preferences for a user. The preferences are returned as a promise that resolves with an array of notification settings. ```js notificationapi.getUserPreferences().then((prefs) => { console.log(prefs); }); ``` -------------------------------- ### Customize Notification Popup Source: https://github.com/pingram-io/docs/blob/main/docs/reference/react-sdk.md Example of customizing the NotificationPopup component with various parameters like image shape, pagination, page size, and page position. ```jsx ``` -------------------------------- ### Inline Mode Example Source: https://github.com/pingram-io/docs/blob/main/docs/components/inapp.md Renders in-app notifications directly onto the parent element without a bell icon or popup. Useful for dedicated notification pages. ```javascript showInApp({ inline: true }) ``` -------------------------------- ### Python Initialize NotificationAPI Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Import and initialize the NotificationAPI SDK for Python. Specify the region by appending the appropriate URL after the client secret if not using the default US region. ```python # import import asyncio from notificationapi_python_server_sdk import ( notificationapi ) # initialize notificationapi (default US region) # if in the CA region, add 'https://api.ca.notificationapi.com' after CLIENT_SECRET # if in the EU region, add 'https://api.eu.notificationapi.com' after CLIENT_SECRET notificationapi.init("CLIENT_ID", "CLIENT_SECRET") ``` -------------------------------- ### NotificationApiConfig.init(baseUrl:) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/ios-sdk.md Initializes NotificationApiConfig with a base URL. ```APIDOC ## func init(baseUrl: String) ### Description Initializes a config object for NotificationAPI. ### Parameters #### Path Parameters - **baseUrl** (String) - Required - The NotificationAPI API base url. ``` -------------------------------- ### Make Generic REST API Call Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Use the `client.rest.generic` method to make custom GET requests to specific API endpoints, such as retrieving in-app notifications. ```javascript // The client implicitly accesses resources under /users/USER_ID // in this example: /users/USER_ID/notifications/INAPP_WEB client.rest.generic('GET', 'notifications/INAPP_WEB'); ``` -------------------------------- ### Send Order Tracking Notification in Python Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Send an order tracking notification using the Python SDK. Ensure you have the SDK installed and configured with your client ID and secret. ```python async def send_notification(): await notificationapi.send( { "type": "order_tracking", "to": { "id": "spongebob.squarepants", "email": "spongebob@squarepants.com" }, "parameters": { "item": "Krabby Patty Burger", "address": "124 Conch Street", "orderId": "1234567890" } } ) # Run the async function asyncio.run(send_notification()) ``` -------------------------------- ### JavaScript Initialization Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Instantiate the NotificationAPI client with your credentials in JavaScript. ```javascript notificationapi = NotificationAPI.new('CLIENT_ID', 'CLIENT_SECRET'); ``` -------------------------------- ### Initialize Python SDK with EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Python SDK specifying the EU region by providing the EU API endpoint as the base_url. This ensures requests are routed to the correct data center. ```python notificationapi.init("CLIENT_ID", "CLIENT_SECRET", "https://api.eu.notificationapi.com") ``` -------------------------------- ### Paginated Mode Example Source: https://github.com/pingram-io/docs/blob/main/docs/components/inapp.md Enables pagination for in-app notifications, displaying a fixed number of notifications per page with navigation controls. Useful for stand-alone notification pages. ```javascript showInApp({ pagination: true, pageSize: 2 }) ``` -------------------------------- ### Initialize PHP SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the NotificationAPI PHP SDK by creating a new instance of the NotificationAPI class with your client ID and secret. This prepares the SDK for use. ```php $notificationapi = new NotificationAPI('CLIENT_ID', 'CLIENT_SECRET'); ``` -------------------------------- ### Initialize Vanilla JS SDK Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Initialize the NotificationAPI client with your clientId and a unique userId for your application. ```js const notificationapi = new NotificationAPI({ clientId: 'YOUR_CLIENT_ID', userId: 'UNIQUE_USER_ID' }); ``` -------------------------------- ### Query Logs with Filters Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Demonstrates how to query logs using various filters such as date range, notification type, channel, user, status, tracking ID, request details, and environment ID. Use this to retrieve specific log entries. ```php $notificationapi->queryLogs([ "dateRangeFilter" => [ "startTime" => 1719600830559, "endTime" => 1719600840559, ], "notificationFilter" => ['order_tracking'], "channelFilter" => ['EMAIL'], "userFilter" => ['abcd-1234'], "statusFilter" => ['SUCCESS'], "trackingIds" => ['172cf2f4-18cd-4f1f-b2ac-e50c7d71891c'], "requestFilter" => ['request.mergeTags.item="Krabby Patty Burger"'], "envIdFilter" => ['6ok6imq9unr2budgiebjdaa6oi'] ]); ``` ```go params := map[string]interface{}{ "dateRangeFilter": map[string]interface{}{ "startTime": 1719600830559, "endTime": 1719600840559, }, "notificationFilter": []string{"order_tracking"}, "channelFilter": []string{"EMAIL"}, "userFilter": []string{"abcd-1234"}, "statusFilter": []string{"SUCCESS"}, "trackingIds": []string{"172cf2f4-18cd-4f1f-b2ac-e50c7d71891c"}, "requestFilter": []string{`request.mergeTags.item="Krabby Patty Burger"`}, "envIdFilter": []string{"6ok6imq9unr2budgiebjdaa6oi"}, } notificationAPI.QueryLogs(params) ``` ```csharp var parameters = new Dictionary { { "dateRangeFilter", new Dictionary { { "startTime", 1719600830559 }, { "endTime", 1719600840559 } } }, { "notificationFilter", new List { "order_tracking" } }, { "channelFilter", new List { "EMAIL" } }, { "userFilter", new List { "abcd-1234" } }, { "statusFilter", new List { "SUCCESS" } }, { "trackingIds", new List { "172cf2f4-18cd-4f1f-b2ac-e50c7d71891c" } }, { "requestFilter", new List { @"request.mergeTags.item=\"Krabby Patty Burger\"" } }, { "envIdFilter", new List { "6ok6imq9unr2budgiebjdaa6oi" } } }; await notificationApi.QueryLogs(parameters); ``` ```java NotificationApi api = new NotificationApi("CLIENT_ID", "CLIENT_SECRET", "https://api.notificationapi.com"); QueryLogsRequest request = new QueryLogsRequest(); request.setDateRangeFilter(new DateRangeFilter(1719600830559, 1719600840559)); request.setNotificationFilter(Arrays.asList("order_tracking")); request.setChannelFilter(Arrays.asList("EMAIL")); request.setUserFilter(Arrays.asList("abcd-1234")); request.setStatusFilter(Arrays.asList("SUCCESS")); request.setTrackingIds(Arrays.asList("172cf2f4-18cd-4f1f-b2ac-e50c7d71891c")); request.setRequestFilter("request.mergeTags.item=\"Krabby Patty Burger\""); request.setEnvIdFilter("6ok6imq9unr2budgiebjdaa6oi"); api.queryLogs(request); ``` ```ruby params = { dateRangeFilter: { startTime: 1719600830559, endTime: 1719600840559 }, notificationFilter: ['order_tracking'], channelFilter: ['EMAIL'], userFilter: ['abcd-1234'], statusFilter: ['SUCCESS'], trackingIds: ['172cf2f4-18cd-4f1f-b2ac-e50c7d71891c'], requestFilter: ['request.mergeTags.item="Krabby Patty Burger"'], envIdFilter: ['6ok6imq9unr2budgiebjdaa6oi'] } notificationapi.query_logs(params) ``` -------------------------------- ### Update User Notification Delivery Option Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-core.md Modify a user's delivery preference for a specific notification type and channel. For example, turn off 'new_comment' notifications via 'INAPP_WEB'. ```javascript await client.updateDeliveryOption({ type: 'new_comment', channel: 'INAPP_WEB', delivery: 'off', }); ``` -------------------------------- ### Client-Side Initialization in Next.js Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-client.md Use the `'use client'` directive and `memo` to ensure client-side execution and prevent SDK reinitialization in Next.js. Dynamic import is used for the SDK. ```jsx 'use client'; import 'notificationapi-js-client-sdk/dist/styles.css'; import { memo, useEffect } from 'react'; const NotificationAPIComponent = memo(() => { useEffect(() => { const loadNotificationAPI = async () => { const NotificationAPI = (await import('notificationapi-js-client-sdk')) .default; const notificationapi = new NotificationAPI({ clientId: 'CLIENT_ID', userId: 'USERS_ID' }); notificationapi.showInApp({ root: 'CONTAINER_DIV_ID' }); }; loadNotificationAPI(); }, []); return
; }); NotificationAPIComponent.displayName = 'NotificationAPIComponent'; export default NotificationAPIComponent; ``` -------------------------------- ### Example $.request Object Source: https://github.com/pingram-io/docs/blob/main/docs/features/logs.md This object shows the structure of a $.request object, which contains original parameters passed to the send() method. It includes type, recipient details, and custom parameters. ```javascript { type: '...', to: { id: '123', email: 'jane@doe.com', number: '+19999999999' }, parameters: { firstName: 'jane' } } ``` -------------------------------- ### Remix Configuration and Integration Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-client.md Configure Remix to bundle the SDK by adding it to `serverDependenciesToBundle`. Include the SDK's CSS in your root component's links. ```js serverDependenciesToBundle: ['notificationapi-js-client-sdk']; // for more info, read: https://remix.run/docs/en/main/guides/gotchas#importing-esm-packages ``` ```js import NotificationAPICSS from 'notificationapi-js-client-sdk/dist/styles.css'; export const links: LinksFunction = () => { return [ { rel: 'stylesheet', href: NotificationAPICSS } // and the other links ... ]; }; ``` ```jsx import NotificationAPIClient from 'notificationapi-js-client-sdk'; import { useEffect } from 'react'; export default function Index() { useEffect(() => { const notificationapi = new NotificationAPIClient({ clientId: 'CLIENT_ID', userId: 'USER_ID' }); notificationapi.showInApp({ root: 'bell-container' }); }, []); return (
); } ``` -------------------------------- ### Looping Through Data in Template Source: https://github.com/pingram-io/docs/blob/main/docs/features/mergetags.md Utilize 'for' loops to iterate over arrays like 'alerts' and display dynamic content for each item. This example shows how to list alert titles and their corresponding URLs. ```md {% for alert in alerts %} Alert: {{alert.title}} URL: https://myapp.com/alerts/{{alert.id}} {% endfor %} ``` -------------------------------- ### Initialize NotificationAPI in Ruby Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md This snippet shows how to require the NotificationAPI library and initialize it with client credentials for the US region. Regional endpoints can be specified. ```ruby # require: require './NotificationAPI' # initialize notificationapi (default US region) # if in the CA region, add 'https://api.ca.notificationapi.com' after CLIENT_SECRET ``` -------------------------------- ### Initialize Node.js SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the NotificationAPI Node.js SDK with your client ID and client secret. This is a required step before making any API calls. ```js notificationapi.init('CLIENT_ID', 'CLIENT_SECRET'); ``` -------------------------------- ### CSS Styling for User Preferences Widget Source: https://github.com/pingram-io/docs/blob/main/docs/components/user-preferences.md Customize the appearance of the user preferences widget by overriding default CSS classes. This example shows how to hide the title and change the toggle switch color. ```css .notificationapi-preferences-popup h1 { display: none !important; } /* Change the toggle color to orange */ .notificationapi-preferences-popup .switch input:checked + i { background-color: orange !important; } ``` -------------------------------- ### Nuxt3 Integration with SDK Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-client.md Initialize the NotificationAPI SDK in the `mounted` hook of a Nuxt3 component, referencing a container element using a ref. Import the SDK's CSS. ```html ``` -------------------------------- ### Basic Conditional Logic in Template Source: https://github.com/pingram-io/docs/blob/main/docs/features/mergetags.md Use 'if' and 'else' statements within the template editor to conditionally display content based on passed parameters. This example shows a greeting that changes based on whether 'firstName' is provided. ```md {% if firstName %} Hello {{firstName}}! {% else %} Hello there! {% endif %} ``` -------------------------------- ### Initialize NotificationAPI SDK Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Initialize the NotificationAPI SDK with your client ID and client secret. If operating in the EU region, append the EU API endpoint to your client secret. ```python notificationapi = NotificationAPI.new("CLIENT_ID", "CLIENT_SECRET") ``` -------------------------------- ### NotificationApi.configure(withCredentials:withConfig:) Source: https://github.com/pingram-io/docs/blob/main/docs/reference/ios-sdk.md Configures the NotificationApi SDK with provided credentials and optional configuration. ```APIDOC ## func configure(withCredentials credentials: NotificationApiCredentials, withConfig config: NotificationApiConfig? = nil) ### Description Configures `NotificationApi` to use your credentials. This should be invoked as early as possible (such as within `application(didFinishLaunchingWithOptions:)`) to ensure that the user does not miss any push notifications. ### Parameters #### Path Parameters - **credentials** (NotificationApiCredentials) - Required - Your NotificationAPI credentials. You can retrieve them from [here](https://app.notificationapi.com/environments). - **config** (NotificationApiConfig) - Optional - Config object for the NotificationApi SDK. ``` -------------------------------- ### Initialize Java SDK for CA Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Java SDK for the CA region by specifying the CA base URL. ```java // For CA region NotificationApi api = new NotificationApi("CLIENT_ID", "CLIENT_SECRET", "https://api.ca.notificationapi.com"); ``` -------------------------------- ### Initialize NotificationAPI SDK with custom service worker path (Vanilla JS) Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Initialize the NotificationAPI client in vanilla JavaScript, specifying a custom path for the service worker file. ```js const notificationapi = new NotificationAPI({ clientId: 'YOUR_CLIENT_ID', userId: 'UNIQUE_USER_ID', customServiceWorkerPath: '/service/notificationapi-service-worker.js' }); ``` -------------------------------- ### Angular CSS Import and SDK Initialization Source: https://github.com/pingram-io/docs/blob/main/docs/reference/js-client.md Import the NotificationAPI SDK's CSS into your global `styles.scss` file. Initialize the SDK within the `ngOnInit` lifecycle hook. ```js @import 'node_modules/notificationapi-js-client-sdk/dist/styles.css' ``` ```jsx import NotificationAPI from 'notificationapi-js-client-sdk'; import {PopupPosition} from 'notificationapi-js-client-sdk/lib/interfaces'; ngOnInit() { const notificationapi = new NotificationAPI({ userId: "USERS_ID", clientId: "CLIENT_ID", }); notificationapi.showInApp({ root: 'bell-container', // root element containing the button popupPosition: PopupPosition.BottomLeft }); } ``` -------------------------------- ### Add Java HTTP Client and Jackson Dependencies Source: https://github.com/pingram-io/docs/blob/main/docs/quick-start/send-a-notification.md Include necessary HTTP client and JSON processing dependencies for the Java SDK. These are recommended for optimal functionality. ```xml org.apache.httpcomponents httpclient 4.5.14 com.fasterxml.jackson.core jackson-databind 2.15.2 ``` -------------------------------- ### Initialize Node.js SDK with EU Region Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Initialize the Node.js SDK specifying the EU region using the baseURL configuration option. Ensure your client ID and secret are correct. ```js import notificationapi from 'notificationapi-node-server-sdk'; notificationapi.init('CLIENT_ID', 'CLIENT_SECRET', { baseURL: 'https://api.eu.notificationapi.com' }); ``` -------------------------------- ### Commit Changes Source: https://github.com/pingram-io/docs/blob/main/README.md Stage all changes and commit them with a title and description. ```bash git add . git commit -m "Title" -m "Description of the changes" ``` -------------------------------- ### Initialize React SDK Provider Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Import and use the NotificationAPIProvider in your top-level React components or routers. Provide your clientId, userId, and optionally a customServiceWorkerPath. ```jsx import { NotificationAPIProvider } from '@notificationapi/react'; {/* your protected routes */} ; ``` -------------------------------- ### Initialize NotificationAPI SDK (UMD) Source: https://github.com/pingram-io/docs/blob/main/docs/guides/web-push.md Initialize the NotificationAPI client with your clientId and userId. This is for UMD script usage. ```js const notificationapi = new NotificationAPI({ clientId: YOUR_CLIENT_ID, userId: UNIQUE_USER_ID }); ``` -------------------------------- ### Identify User with Push and Web Push Tokens Source: https://github.com/pingram-io/docs/blob/main/docs/reference/server.md Demonstrates how to identify a user with their email, phone number, FCM push tokens, and web push tokens across different platforms. ```php $user = [ 'id' => 'spongebob.squarepants', 'email' => 'spongebob.squarepants.com', 'number' => '+15005550006', 'pushTokens' => [ [ 'type' => 'FCM', 'token' => 'samplePushToken', 'device' => [ 'app_id' => 'com.example.app', 'ad_id' => '1234567890', 'device_id' => '1234567890', 'platform' => 'android', 'manufacturer' => 'Samsung', 'model' => 'SM-G930F' ] ] ], 'webPushTokens' => [ [ 'sub' => [ 'endpoint' => 'https://fcm.googleapis.com/fcm/send/fCs_4iba0Ao:APA91bGFdaU7I3****JMH_KeZwk1Xi', 'keys' => [ 'p256dh' => 'zP2xFu3hMc2vNH5E2nuKkyjpZydvCk9llRUY2kP4****9aSlKcoadSV2UbvMRQ', 'auth' => 'CXEFun************tYe8g' ] ] ] ] ]; $notificationAPI->identifyUser($user); ```