### Installation API Response Structure Source: https://docs.wonderpush.com/reference/get-installations Example of the JSON response returned by the installations endpoint, containing installation data and pagination links. ```json { "count": 123, "data": [ { "id": "e2ba48f97a45be39f6c921e7b7a2adf65ad451b5", "applicationId": "01906i1feoq2cu1p", "userId": null, "creationDate": 1410539794529, "updateDate": 1410539796299, "accessToken": "Hkn6z9fZCOEiqNn8ESSLkQx7fz5EyCEUJBvoRtasoqT2LDYPxDOh4ftGQRpnEn71NFw4VPQdySx8gJi7xrwHWl", "application": { "id": "01906i1feoq2cu1p", "sdkVersion": "Android-1.1.0.0", "version": "1.0" }, "device": { "id": "c51c72f4a3700183", "platform": "Android", "screenHeight": 1186, "model": "Nexus 4", "osVersion": "19", "screenWidth": 768, "brand": "LGE", "configuration": { "locale": "fr_FR", "carrier": "Bouygues Telecom", "timeZone": "Europe/Paris" }, "screenDensity": 320 }, "preferences": { "subscriptionStatus": "optIn" }, "pushToken": { "meta": { "updateDate": 1410539796298 }, "data": "02J0fDm4dwsAylLXKr47YhN9CfjU9AimDSXVKL83OnPVwEaZU1EfcLww5LGlye_5mGGgaGcbrXtXU6HKCUXabGUHBNX0V4htJvHBAflIgABe4H5SskfwA_Ie3WHmjAfiy2whXUvMWK5gH6jRZOwQJltiMbilfoPxvF" }, "custom": { "int_age": 27, "string_foo": "bar", "string_likes": ["pizza", "beer"] } }, //... ], "pagination": { "previous": null, "next": "https://management-api.wonderpush.com/v1/installations?accessToken=YOUR_APPLICATION_ACCESS_TOKEN&limit=50&pretty=0&applicationId=01906i1feoq2cu1p&next=0GwZy6UsvjVdYTT59ChWqcr14HeMLmYrpKi3SfR8ilMYmr5xKxgL9HU5fpNSLCfXQPyicvW766zImO7qu_CyWfZuJXm0oR1No5yRyPcAPllNTc0dma4H5xnqhKXDbswsK8J-H9f5Wipufzpi1AihZr7rNoXXnBv43wmDM6pxbNo" } } ``` -------------------------------- ### Get Installation Properties Source: https://docs.wonderpush.com/docs/website-sdk-reference Retrieves a promise that resolves with an object containing all properties of the current installation. Use this to inspect current settings. ```javascript window.WonderPush = window.WonderPush || []; WonderPush.push(function() { WonderPush.getProperties().then(function(properties) { console.log("Properties of the current installation are:", properties); }); }); ``` -------------------------------- ### Properties API Source: https://docs.wonderpush.com/docs/cordova-sdk APIs for getting and setting installation properties. ```APIDOC ## GET /properties ### Description Returns all the name/value pairs associated with this installation. ### Method GET ### Endpoint /properties ### Response #### Success Response (200) - **properties** (object) - Key-value pairs of properties. ### Response Example ```json { "properties": { "exampleKey": "exampleValue" } } ``` ## PUT /properties ### Description Sets name/value pairs associated with this installation. ### Method PUT ### Endpoint /properties ### Request Body - **properties** (object) - Key-value pairs of properties to set. ### Request Example ```json { "properties": { "newKey": "newValue" } } ``` ``` -------------------------------- ### Retrieve Installation Properties Source: https://docs.wonderpush.com/docs/ios-sdk Retrieves the current installation properties as a dictionary. ```swift let properties = WonderPush.getProperties() let name = properties?["string_name"] ``` ```objectivec NSDictionary *properties = [WonderPush getProperties]; NSString *name = properties[@"string_name"]; ``` -------------------------------- ### Retrieve installation properties Source: https://docs.wonderpush.com/docs/cordova-sdk Fetches all properties associated with the current installation via a callback. ```javascript WonderPush.getProperties(function(properties) { console.log("Properties: ", properties); }); ``` -------------------------------- ### GET /installations/{installationId} Source: https://docs.wonderpush.com/reference/get-installations-installationid Retrieves the details of a specific installation by its ID. ```APIDOC ## GET /installations/{installationId} ### Description Get an installation by its unique identifier. ### Method GET ### Endpoint https://management-api.wonderpush.com/v1/installations/{installationId} ### Parameters #### Path Parameters - **installationId** (string) - Required - Id of the installation to retrieve. #### Query Parameters - **userId** (string) - Required - Id of the associated user. Leave empty for `null`. - **fields** (array) - Optional - Comma separated list of fields to return. ### Response #### Success Response (200) - **id** (string) - The installation ID. - **creationDate** (integer) - The creation timestamp. - **updateDate** (integer) - The last update timestamp. - **userId** (any) - The associated user ID. - **applicationId** (string) - The application ID. - **accessToken** (string) - The access token. - **application** (object) - Application details. - **device** (object) - Device details. #### Response Example { "id": "e3e2d060c9c92ae72f5b90461fc65188863092b7", "creationDate": 1436185983232, "updateDate": 1436185983553, "userId": null, "applicationId": "01906i1feoq2cu1p", "accessToken": "AgJWds5SDcMqc1Jb6LTAdsUhh2vPyaeucbPUagRfkwRGCszVRxY5kD0OnWClaOuGShU04V1sP1yagBM5KHmc0n", "application": { "id": "01906i1feoq2cu1p", "sdkVersion": "iOS-1.2.0.0", "version": "1.0.0" }, "device": { "id": "97AF80A7-5D37-4C74-309B-BCD692A8E412", "platform": "iOS", "screenHeight": 1024, "model": "iPad 4 (WiFi)", "osVersion": "8.3", "screenWidth": 768, "name": "John Doe's iPad", "brand": "Apple", "screenDensity": 2 } } ``` -------------------------------- ### Retrieve Installation Details Source: https://docs.wonderpush.com/reference/get-installations-installationid Use this cURL command to fetch installation data from the WonderPush Management API. ```curl curl -XGET "https://management-api.wonderpush.com/v1/installations/bfbd475402abf833c226a7144ad9f7cb45629abc?accessToken=YOUR_APPLICATION_ACCESS_TOKEN&userId=" ``` -------------------------------- ### Retrieve installation properties Source: https://docs.wonderpush.com/docs/popup-sdk-reference Returns a Promise that resolves to an object containing the current installation properties. ```javascript WonderPushPopupSDK.getProperties().then(function(properties) { console.log("Properties of the current installation are:", properties); }); ``` -------------------------------- ### GET /v1/installations Source: https://docs.wonderpush.com/docs/api-authentication Retrieves a list of installations for the application. Authentication is performed via the accessToken query parameter. ```APIDOC ## GET /v1/installations ### Description Retrieves the list of installations associated with the application. ### Method GET ### Endpoint https://management-api.wonderpush.com/v1/installations ### Parameters #### Query Parameters - **accessToken** (string) - Required - The access token found on the API Credentials page of the dashboard. ``` -------------------------------- ### Retrieve all installation tags Source: https://docs.wonderpush.com/docs/react-native-sdk Returns a promise resolving to an array of all tags attached to the current installation. ```javascript const tags = await WonderPush.getTags(); console.log("User tags:", tags.join(', ')); ``` -------------------------------- ### GET /properties Source: https://docs.wonderpush.com/docs/react-native-sdk Returns a promise resolving with an object containing the properties of the current installation. ```APIDOC ## GET /properties ### Description Returns a promise resolving with an object containing the properties of the current installation. ### Method GET ### Endpoint /properties ### Response #### Success Response (200) - **properties** (Object) - An object containing the user's properties. #### Response Example ```json { "int_age": 34, "string_name": "John Doe" } ``` ``` -------------------------------- ### Get All Properties Source: https://docs.wonderpush.com/docs/android-sdk Retrieves a JSONObject containing all properties associated with the current installation. ```java JSONObject properties = WonderPush.getProperties(); String name = properties.optString("string_name"); ``` -------------------------------- ### GET /installations Source: https://docs.wonderpush.com/reference/get-installations Retrieves a list of installations based on optional segment and tag filters. ```APIDOC ## GET /installations ### Description Retrieves a list of installations. Supports filtering by segments and tags. Results are paginated. ### Method GET ### Endpoint /v1/installations ### Parameters #### Query Parameters - **viewId** (string) - Optional - Optional view id to apply over all segments defined in the Full view. - **segmentIds** (string) - Optional - Segment ids the installations to list must match. Cannot be used with criteria. - **segmentParams** (string) - Optional - JSON dictionary of parameters to be applied to the segment. - **tags** (string) - Optional - Tags the installations to list must have. ### Response #### Success Response (200) - **count** (integer) - Total number of installations found. - **data** (array) - List of installation objects. - **pagination** (object) - Pagination links for navigating results. #### Response Example { "count": 123, "data": [ { "id": "e2ba48f97a45be39f6c921e7b7a2adf65ad451b5", "applicationId": "01906i1feoq2cu1p", "userId": null, "creationDate": 1410539794529, "updateDate": 1410539796299, "accessToken": "Hkn6z9fZCOEiqNn8ESSLkQx7fz5EyCEUJBvoRtasoqT2LDYPxDOh4ftGQRpnEn71NFw4VPQdySx8gJi7xrwHWl", "application": { "id": "01906i1feoq2cu1p", "sdkVersion": "Android-1.1.0.0", "version": "1.0" }, "device": { "id": "c51c72f4a3700183", "platform": "Android", "screenHeight": 1186, "model": "Nexus 4", "osVersion": "19", "screenWidth": 768, "brand": "LGE", "configuration": { "locale": "fr_FR", "carrier": "Bouygues Telecom", "timeZone": "Europe/Paris" }, "screenDensity": 320 }, "preferences": { "subscriptionStatus": "optIn" }, "pushToken": { "meta": { "updateDate": 1410539796298 }, "data": "02J0fDm4dwsAylLXKr47YhN9CfjU9AimDSXVKL83OnPVwEaZU1EfcLww5LGlye_5mGGgaGcbrXtXU6HKCUXabGUHBNX0V4htJvHBAflIgABe4H5SskfwA_Ie3WHmjAfiy2whXUvMWK5gH6jRZOwQJltiMbilfoPxvF" }, "custom": { "int_age": 27, "string_foo": "bar", "string_likes": ["pizza", "beer"] } } ], "pagination": { "previous": null, "next": "https://management-api.wonderpush.com/v1/installations?accessToken=YOUR_APPLICATION_ACCESS_TOKEN&limit=50&pretty=0&applicationId=01906i1feoq2cu1p&next=0GwZy6UsvjVdYTT59ChWqcr14HeMLmYrpKi3SfR8ilMYmr5xKxgL9HU5fpNSLCfXQPyicvW766zImO7qu_CyWfZuJXm0oR1No5yRyPcAPllNTc0dma4H5xnqhKXDbswsK8J-H9f5Wipufzpi1AihZr7rNoXXnBv43wmDM6pxbNo" } } ``` -------------------------------- ### Install Pods Source: https://docs.wonderpush.com/docs/cocoapods-integration After updating your Podfile, run this command to install the WonderPush and WonderPushExtension pods into your project. ```bash pod install ``` -------------------------------- ### Installation Information API Source: https://docs.wonderpush.com/docs/cordova-sdk APIs for retrieving unique installation and push token identifiers. ```APIDOC ## GET /installationId ### Description Returns the installationId identifying this installation in your application. ### Method GET ### Endpoint /installationId ### Response #### Success Response (200) - **installationId** (string) - The unique installation identifier. ### Response Example ```json { "installationId": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ## GET /pushToken ### Description Returns the push token (also called registration id by FCM). ### Method GET ### Endpoint /pushToken ### Response #### Success Response (200) - **pushToken** (string) - The device's push token. ### Response Example ```json { "pushToken": "APA91b..." } ``` ``` -------------------------------- ### Installation Properties API Source: https://docs.wonderpush.com/docs/ios-sdk Methods for managing key-value properties associated with a specific installation. ```APIDOC ## getPropertyValue ### Description Returns the value of a given property associated to this installation. ## getPropertyValues ### Description Returns an immutable list of the values of a given property associated to this installation. ## addProperty ### Description Adds the value to a given property associated to this installation. ## removeProperty ### Description Removes the value from a given property associated to this installation. ## setProperty ### Description Sets the value to a given property associated to this installation. ## unsetProperty ### Description Removes the value of a given property associated to this installation. ## putProperties ### Description Associates the provided name/value pairs to this installation. ## getProperties ### Description Returns all the name/value pairs associated to this installation. ``` -------------------------------- ### Install React WonderPush SDK Source: https://docs.wonderpush.com/docs/web-push-notifications-react Install the react-wonderpush package using Yarn or NPM. ```shell yarn add react-wonderpush ``` ```shell npm i react-wonderpush ``` -------------------------------- ### Manage Installation Tags Source: https://docs.wonderpush.com/docs/popup-sdk-reference Methods for adding, removing, checking, and retrieving tags associated with the current installation. ```javascript WonderPushPopupSDK.addTag("customer"); WonderPushPopupSDK.addTag("economics", "sport", "politics"); ``` ```javascript WonderPushPopupSDK.removeTag("customer"); WonderPushPopupSDK.removeTag("economics", "sport", "politics"); ``` ```javascript WonderPushPopupSDK.hasTag("customer").then(function(isCustomer) { if (isCustomer) { // Display paid features } }); ``` ```javascript WonderPushPopupSDK.getTags().then(function(tags) { // Work on the tags variable }); ``` -------------------------------- ### Retrieve Installations via cURL Source: https://docs.wonderpush.com/reference/get-installations Use this cURL command to fetch installation data from the WonderPush management API. ```curl curl -XGET "https://management-api.wonderpush.com/v1/installations?accessToken=YOUR_APPLICATION_ACCESS_TOKEN" ``` -------------------------------- ### GET /v1/installations/{installationId} Source: https://docs.wonderpush.com/reference/get-installations-installationid Retrieves detailed information about a specific installation, including device properties, push token, and custom data. This endpoint is useful for inspecting individual user or device configurations. ```APIDOC ## GET /v1/installations/{installationId} ### Description Retrieves detailed information about a specific installation, including device properties, push token, and custom data. ### Method GET ### Endpoint /v1/installations/{installationId} ### Parameters #### Path Parameters - **installationId** (string) - Required - The unique identifier for the installation. #### Query Parameters - **accessToken** (string) - Required - Your application's access token. - **userId** (string) - Optional - The user ID associated with the installation. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **installationId** (string) - The unique identifier for the installation. - **device** (object) - Information about the device. - **type** (string) - The type of device (e.g., "mobile", "desktop"). - **model** (string) - The device model (e.g., "iPad 4 (WiFi)"). - **osVersion** (string) - The operating system version (e.g., "8.3"). - **screenWidth** (integer) - The screen width in pixels. - **name** (string) - A user-defined name for the device. - **brand** (string) - The brand of the device (e.g., "Apple"). - **screenDensity** (integer) - The screen density. - **pushToken** (object) - Information about the push token. - **data** (string) - The push token data. - **meta** (object) - Metadata for the push token. - **updateDate** (integer) - The date the push token was last updated, in milliseconds since the epoch. - **custom** (object) - Custom data associated with the installation. - **int_age** (integer) - An example custom integer field. - **string_foo** (string) - An example custom string field. - **string_likes** (array) - An example custom array of strings. - **items** (string) - An item in the array of likes. #### Response Example ```json { "installationId": "bfbd475402abf833c226a7144ad9f7cb45629abc", "device": { "type": "tablet", "model": "iPad 4 (WiFi)", "osVersion": "8.3", "screenWidth": 768, "name": "John Doe's iPad", "brand": "Apple", "screenDensity": 2 }, "pushToken": { "data": "d94e486c61cde836c50dae573ba4903ca1aed973792e53128fd7d6bb0c657d17", "meta": { "updateDate": 1436186029623 } }, "custom": { "int_age": 27, "string_foo": "bar", "string_likes": [ "pizza" ] } } ``` #### Error Response (400) - **error** (object) - Contains error details. - **status** (integer) - The HTTP status code of the error. - **code** (string) - An error code specific to the API. - **message** (string) - A human-readable error message. #### Error Response Example ```json { "error": { "status": 400, "code": "10002", "message": "Missing parameter userId" } } ``` ``` -------------------------------- ### Retrieve Installation Properties Source: https://docs.wonderpush.com/docs/flutter-sdk Returns a promise resolving with an object containing the current installation properties. ```Dart var properties = await WonderPush.getProperties(); print("Properties: $properties"); ``` -------------------------------- ### Installation and User Info Source: https://docs.wonderpush.com/docs/android-sdk Methods to retrieve identifiers and push tokens associated with the current installation. ```APIDOC ## getUserId ### Description Returns the user ID you've assigned to this installation if any. ## getInstallationId ### Description Returns the installationId identifying this installation in your application. ## getPushToken ### Description Returns the push token (also called registration id by FCM). ``` -------------------------------- ### Retrieve Installation Properties Source: https://docs.wonderpush.com/docs/popup-sdk-reference Methods for reading single or multiple values from installation properties. ```javascript WonderPushPopupSDK.getPropertyValue("string_lastname").then(function(lastName) { // Use lastName }); ``` ```javascript WonderPushPopupSDK.getPropertyValues("string_favoritePlayers").then(function(favoritePlayers) { // Use favoritePlayers array }); ``` -------------------------------- ### Add Tags to Installation Source: https://docs.wonderpush.com/docs/website-sdk-reference Applies one or more tags to the current user installation. Tags can be used for segmentation. ```javascript window.WonderPush = window.WonderPush || []; WonderPush.push(function() { WonderPush.addTag("customer"); WonderPush.addTag("economics", "sport", "politics"); }); ``` -------------------------------- ### User and Installation Management Source: https://docs.wonderpush.com/docs/flutter-sdk APIs for managing user identification and installation details. ```APIDOC ## POST /api/setUserId ### Description Assigns a custom user ID to the current installation. ### Method POST ### Endpoint /api/setUserId ### Parameters #### Request Body - **userId** (string) - Required - The custom user ID to assign. ### Request Example ```json { "userId": "user-12345" } ``` ## GET /api/getUserId ### Description Returns the custom user ID assigned to this installation, if any. ### Method GET ### Endpoint /api/getUserId ### Response #### Success Response (200) - **userId** (string) - The assigned user ID or null if none is set. #### Response Example ```json { "userId": "user-12345" } ``` ## GET /api/getInstallationId ### Description Returns the unique installation ID that identifies this installation within your application. ### Method GET ### Endpoint /api/getInstallationId ### Response #### Success Response (200) - **installationId** (string) - The unique installation ID. #### Response Example ```json { "installationId": "install-abcde" } ``` ## GET /api/getPushToken ### Description Returns the push token (also known as the registration ID by FCM). ### Method GET ### Endpoint /api/getPushToken ### Response #### Success Response (200) - **pushToken** (string) - The push token. #### Response Example ```json { "pushToken": "APA91b...". } ``` ``` -------------------------------- ### Export All Installations to JSON Lines Source: https://docs.wonderpush.com/reference/pagination Use this Python snippet to export all installations from the WonderPush API. It iterates through paginated results and prints each installation as a JSON object on a new line to standard output. Ensure you replace YOUR_ACCESS_TOKEN with your actual access token. ```python for item in iterate('https://management-api.wonderpush.com/v1/installations', query={'accessToken': YOUR_ACCESS_TOKEN, 'limit': 1000}): print(json.dumps(item)) ``` -------------------------------- ### Add tags to an installation Source: https://docs.wonderpush.com/docs/react-native-sdk Adds one or more tags to the current installation. Returns a promise to await for completion. ```javascript // One tag at a time await WonderPush.addTag("customer"); // Multiple tags at once await WonderPush.addTag(["economics", "sport", "politics"]); ``` -------------------------------- ### Sample Installation Object Source: https://docs.wonderpush.com/docs/the-installation-object This JSON object represents a typical WonderPush installation. It includes details about the application, device, user, and push token. ```json { "id": "e2ba48f97a45be39f6c921e7b7a2adf65ad451b5", "applicationId": "01906i1feoq2cu1p", "userId": null, "creationDate": 1410539794529, "updateDate": 1410539796299, "accessToken": "Hkn6z9fZCEUJBvoRtasoqT2LDYPxDOh4ftGQRpnEn71NFw4VPQdySx8gJi7xrwHWl", "application": { "id": "01906i1feoq2cu1p", "integrator": "wonderpush-cordova-sdk-2.0.0", "sdkVersion": "Android-1.1.0.0", "version": "1.0", "apple": { "appId": "com.mycompany.myiosapp", "apsEnvironment": "production", "backgroundModes": ["remote-notification"] }, "android": { "applicationId": "com.mycompany.myandroidapp" } }, "device": { "id": "c51c72f4a3700183", "federatedId": "0:ef5c2057-7b49-49f8-835e-e4dd615069a2", "platform": "Android", "screenHeight": 1186, "model": "Nexus 4", "osVersion": "19", "screenWidth": 768, "brand": "LGE", "configuration": { "carrier": "Bouygues Telecom", "country": "FR", "currency": "EUR", "locale": "fr_FR", "timeZone": "Europe/Paris" }, "screenDensity": 320 }, "preferences": { "subscriptionStatus": "optIn", "subscribedToNotifications": true, "osNotificationsVisible": true, "disabledAndroidChannels": ["foo", "bar"] }, "pushToken": { "meta": { "updateDate": 1410539796298 }, "data": "02J0fDm4dwsAylLXKr47YhNwEaZU1EfcLww5LGlye_5mGGgaGcbrXtXU6HKCUXabGUHBNX0V4htJvHBAflIgABe4H5SskfwA_Ie3WHmjAfiy2whXUvMWK5gH6jRZOwQJltiMbilfoPxvF", "senderIds": ["123456789"], "applicationServerKey": "base64urlsafe", "auth": "base64urlsafe", "p256dh": "base64urlsafe", "expirationDate": 1577836799999, "origin": "https://your.domain", "userVisibleOnly": true }, "custom": { "tags": ["foo", "bar"], "byte_foo": 127, "short_foo": 32767, "int_foo": 2147483647, "long_foo": 9223372036854775807, "float_foo": 0.0, "double_foo": 0.0, "bool_foo": true, "string_foo": "bar", "date_foo": "2019-12-31T23:59:59.999Z", "date_bar": 1577836799999, "geoloc_foo": {"lat": 48.85837, "lon": 2.294481}, "geoloc_bar": "48.85837,2.294481", "geoloc_qux": [2.294481, 48.85837], "string_anyPropertyType": ["can", "also", "store", "an", "array"] } } ``` -------------------------------- ### Delete an installation using cURL Source: https://docs.wonderpush.com/reference/delete-installations-installationid Example request to delete an installation using the DELETE method. ```bash curl -XDELETE https://management-api.wonderpush.com/v1/installations/bfbd475402abf833c226a7144ad9f7cb45629abc?accessToken=YOUR_APPLICATION_ACCESS_TOKEN&userId= ``` -------------------------------- ### Get Installation ID Source: https://docs.wonderpush.com/docs/react-native-sdk Retrieves the unique installation ID, which is available after SDK initialization and server contact. ```javascript const installationId = await WonderPush.getInstallationId(); console.log("InstallationId:", installationId); ``` -------------------------------- ### Create an installation with custom properties Source: https://docs.wonderpush.com/docs/import-push-tokens Include additional segmentation data within the installation object using the custom key. ```curl curl -XPUT https://management-api.wonderpush.com/v1/installations/YOUR_INSTALLATION_ID \ -d accessToken="YOUR_ACCESS_TOKEN" \ -d userId= \ -d body='{"pushToken": {"data": "YOUR_PUSH_TOKEN"}, "custom": {"YOUR_PROPERTY": "YOUR_PROPERTY_VALUE"}}' ``` -------------------------------- ### Get Installation ID Source: https://docs.wonderpush.com/docs/flutter-sdk Returns a promise resolved with the installation ID, or `null` if it is not available yet. The Installation ID is obtained asynchronously after the SDK is initialized. ```Flutter / Dart var installationId = await WonderPush.getInstallationId(); print("InstallationId: $installationId"); ``` -------------------------------- ### Initialize WonderPush for Localhost Source: https://docs.wonderpush.com/docs/troubleshooting-website Configure the SDK with customDomain and allowedSubscriptionDomains to enable local testing. ```html ``` -------------------------------- ### Get Installation ID Source: https://docs.wonderpush.com/docs/cordova-sdk Retrieves the unique Installation ID for the current installation. The callback receives the ID as a string or null if it's not yet available. The ID is obtained asynchronously after SDK initialization. ```javascript WonderPush.getInstallationId(function(installationId) { console.log("Installation ID:", installationId); }); ``` -------------------------------- ### Create an installation via API Source: https://docs.wonderpush.com/docs/import-push-tokens Perform an update installation API call to register a push token. The userId parameter is mandatory even if empty. ```curl curl -XPUT https://management-api.wonderpush.com/v1/installations/YOUR_INSTALLATION_ID \ -d accessToken="YOUR_ACCESS_TOKEN" \ -d userId= \ -d body='{"pushToken": {"data": "YOUR_PUSH_TOKEN"}}' ``` -------------------------------- ### Get All Tags Source: https://docs.wonderpush.com/docs/website-sdk-reference Retrieves all tags currently attached to the installation. ```APIDOC ## GET getTags ### Description Returns all the tags attached to the current installation as a promise resolving to an array of strings. ### Method GET ### Endpoint /getTags ### Response #### Success Response (200) - **tags** (String[]) - An array of tags. ### Response Example ```json { "tags": ["customer", "active"] } ``` ``` -------------------------------- ### Installation Info API Source: https://docs.wonderpush.com/docs/flutter-sdk APIs for retrieving installation-specific information. ```APIDOC ## `getInstallationId` ### Description Returns a promise resolved with the installationId, or `null` if it is not available yet. Note: The Installation ID is obtained asynchronously after the WonderPush SDK is initialized and has contacted the WonderPush servers. Changing the User ID will make the SDK use a new installation and this asynchronous process starts anew. Once the SDK has obtained an Installation ID, it will remember it for subsequent use and it will be available right away. ### Method GET ### Endpoint /api/sdk/get-installation-id ### Response #### Success Response (200) - **installationId** (String | null) - The installationId, or `null`. #### Response Example ```json { "installationId": "some_installation_id" } ``` ## `getPushToken` ### Description Returns a promise resolving with the push token of this installation, or `null`. ### Method GET ### Endpoint /api/sdk/get-push-token ### Response #### Success Response (200) - **pushToken** (String | null) - The push token, or `null`. #### Response Example ```json { "pushToken": "some_push_token" } ``` ``` -------------------------------- ### Get Push Token Source: https://docs.wonderpush.com/docs/react-native-sdk Retrieves the push token associated with the current installation. ```javascript const pushToken = await WonderPush.getPushToken(); console.log("Push token:", pushToken); ``` -------------------------------- ### Get User ID Source: https://docs.wonderpush.com/docs/react-native-sdk Retrieves the currently assigned user ID for the installation. ```javascript const userId = await WonderPush.getUserId(); console.log("UserId:", userId); ``` -------------------------------- ### WonderPush.push(['init', options]) Source: https://docs.wonderpush.com/docs/website-sdk-reference Initializes the WonderPush SDK. This must be called on every page before any other WonderPush functions are used. ```APIDOC ## WonderPush.push(['init', options]) ### Description Initializes the WonderPush SDK. This call is required before any other function can be used. Calling this more than once has no effect. ### Parameters #### Request Body - **webKey** (String) - Required - The web key of your project found in the dashboard settings. - **userId** (String) - Optional - The unique identifier of the user in your systems. - **applicationName** (String) - Optional - The name of your website. - **applicationVersion** (String) - Optional - The version of your website for segmentation. - **geolocation** ("auto" or Boolean) - Optional - Report the geolocation of this installation. Defaults to "auto". - **notificationIcon** (String) - Optional - The absolute URL to the notification icon. - **notificationDefaultUrl** (String) - Optional - The default URL opened when users click on notifications. - **requiresUserConsent** (Boolean) - Optional - Whether user consent is required. ### Request Example ```javascript window.WonderPush = window.WonderPush || []; WonderPush.push(["init", { webKey: "YOUR_WEBKEY", userId: "user123", applicationName: "My Website" }]); ``` ``` -------------------------------- ### Get Installation Property Value Source: https://docs.wonderpush.com/docs/android-sdk Retrieves the value of a property associated with the current installation. Returns `JSONObject.NULL` if the property is absent. Always check the type of the returned value. ```java Object value = WonderPush.getPropertyValue("string_lastname"); // You should always check the type of the returned value, especially as `JSONObject.NULL` is used when there is no value if (value instanceof String) { String lastName = (String) value; // Use lastName } ``` -------------------------------- ### Batch Import Multiple Installations Source: https://docs.wonderpush.com/docs/migrate-your-ios-app-from-accengage-to-wonderpush For importing a large number of subscribers, use the `/batch` method to create multiple installations in a single API call. Adapt `YOUR_APPLICATION_ACCESS_TOKEN`, `INSTALLATION_ID_1`, `PUSH_TOKEN_1`, etc., for each subscriber. ```curl curl -XPOST https://management-api.wonderpush.com/v1/batch \ -d accessToken=YOUR_APPLICATION_ACCESS_TOKEN \ -d body='{"requests":[{"method":"POST","path":"/v1/installations/INSTALLATION_ID_1","args":{"userId":"","overwrite":true},"body":{"pushToken":{"data":"PUSH_TOKEN_1"},"device":{"platform":"iOS"}}},{"method":"POST","path":"/v1/installations/INSTALLATION_ID_2","args":{"userId":"","overwrite":true},"body":{"pushToken":{"data":"PUSH_TOKEN_2"},"device":{"platform":"iOS"}}}]}' ``` -------------------------------- ### Listen for session initialization Source: https://docs.wonderpush.com/docs/website-sdk-reference Use this pattern to reliably retrieve the installationId once the SDK session state reaches INIT_SUCCESS. ```javascript new Promise((resolve, reject) => { window.WonderPush = window.WonderPush || []; WonderPush.push(function() { if (WonderPush.getSessionState() === WonderPush.SessionState.INIT_SUCCESS) { WonderPush.getInstallationId().then(resolve, reject); return; } var listener = function(event) { if (event.detail.name !== 'session') return; if (event.detail.state === WonderPush.SessionState.INIT_SUCCESS) { window.removeEventListener('WonderPushEvent', listener); WonderPush.getInstallationId().then(resolve, reject); }; }; window.addEventListener('WonderPushEvent', listener); }); }).then(installationId => { // Do something with the installationId }); ``` -------------------------------- ### Property Management Methods Source: https://docs.wonderpush.com/docs/website-sdk-reference Methods for getting, setting, and removing properties associated with the installation. ```APIDOC ## Property Management ### Methods - **getPropertyValue(property)**: Returns the value of a given property. - **getPropertyValues(property)**: Returns an immutable list of values for a given property. - **addProperty(property, value)**: Adds the value to a given property. - **removeProperty(property, value)**: Removes the value from a given property. - **setProperty(property, value)**: Sets the value to a given property. - **unsetProperty(property)**: Removes the value of a given property. - **putProperties(properties)**: Associates the provided name/value pairs to this installation. - **getProperties()**: Returns all the name/value pairs associated to this installation. ``` -------------------------------- ### POST /installations/{installationId} Source: https://docs.wonderpush.com/reference/post-installations-installationid Create or update an installation record for a specific device. ```APIDOC ## POST /installations/{installationId} ### Description Create or update an installation. The installationId can be a known ID or a combination of device platform and device ID. ### Method POST ### Endpoint /installations/{installationId} ### Parameters #### Path Parameters - **installationId** (string) - Required - Id of an installation if you know it, or alternatively the device platform and device id joined by a colon. #### Request Body - **userId** (string) - Required - Id of the associated user. Leave empty for null. - **body** (string) - Required - JSON body. - **overwrite** (boolean) - Required - Whether to overwrite the whole object or to partially update it. ### Request Example { "userId": "user123", "body": "{\"key\": \"value\"}", "overwrite": true } ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example { "success": true } ``` -------------------------------- ### Get Push Token Source: https://docs.wonderpush.com/docs/flutter-sdk Returns a promise resolving with the push token of this installation, or `null`. ```Flutter / Dart var pushToken = await WonderPush.getPushToken(); print("Push token: $pushToken"); ``` -------------------------------- ### Register a callback in iOS Source: https://docs.wonderpush.com/docs/advanced-click-handling Register a callback named 'example' within the AppDelegate's didFinishLaunchingWithOptions method. ```swift // Put the following call in the [application:didFinishLaunchingWithOptions:] method of your AppDelegate // Here is how to register the callback named "example" NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "example"), object: nil, queue: nil, using: {notification in let arg = notification.userInfo?[WP_REGISTERED_CALLBACK_PARAMETER_KEY] as? String // Do something useful here }) ``` ```objectivec // Put the following call in the [application:didFinishLaunchingWithOptions:] method of your AppDelegate // Here is how to register the callback named "example" [[NSNotificationCenter defaultCenter] addObserverForName:@"example" object:nil queue:nil usingBlock:^(NSNotification *note) { NSString *arg = [note.userInfo objectForKey:WP_REGISTERED_CALLBACK_PARAMETER_KEY]; // Do something useful here }]; ``` -------------------------------- ### Migration: Init Method Source: https://docs.wonderpush.com/docs/website-sdk-reference Example of migrating the `init` method call from the old syntax to the new `push` array syntax. ```APIDOC ## Migration: Init Method ### Description This section illustrates how to update your initialization calls from the deprecated `WonderPush.init()` method to the recommended `WonderPush.push()` method using array syntax. ### Method `push` (with array argument) ### Endpoint N/A (Client-side SDK configuration) ### Parameters N/A ### Request Example ```javascript // DEPRECATED // WonderPush.init({ // webKey: "YOUR_WEBKEY", // }); // VALID window.WonderPush = window.WonderPush || []; WonderPush.push(["init", { webKey: "YOUR_WEBKEY", }]); ``` ### Response N/A ``` -------------------------------- ### Setup WonderPush as Application Delegate Source: https://docs.wonderpush.com/docs/ios-sdk Installs WonderPush as the application delegate to automatically intercept and forward calls. ```swift func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { WonderPush.setupDelegateForApplication(application) } ``` ```objectivec - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [WonderPush setupDelegateForApplication:application]; } ``` -------------------------------- ### Get User ID Source: https://docs.wonderpush.com/docs/flutter-sdk Returns a promise resolving with the user ID assigned to this installation, or `null` by default. ```Flutter / Dart var userId = await WonderPush.getUserId(); print("UserId: $userId"); ``` -------------------------------- ### Initialization Methods Source: https://docs.wonderpush.com/docs/ios-sdk Methods for initializing the WonderPush SDK and configuring delegates. ```APIDOC ## setClientId:secret: ### Description Initializes the SDK with your client ID and secret. ## setupDelegateForApplication ### Description Installs WonderPush as your AppDelegate. ## setupDelegateForUserNotificationCenter ### Description Installs WonderPush as UNUserNotificationCenter delegate. ## setLogging ### Description Controls SDK logging. ## isInitialized ### Description Returns whether the WonderPush SDK has been given the clientId and clientSecret. ## isReady ### Description Returns whether the WonderPush SDK is ready to operate. ## setDelegate ### Description Sets the delegate for the WonderPushSDK. ``` -------------------------------- ### Initialize SDK via JavaScript Source: https://docs.wonderpush.com/docs/troubleshooting-website Alternative method to load the SDK when adding a script tag is not possible. ```javascript (function(){ var js = document.createElement('script'); js.src = 'https://cdn.by.wonderpush.com/sdk/1.1/wonderpush-loader.min.js'; js.async = true; document.head.appendNode(js); })(); window.WonderPush = window.WonderPush || []; WonderPush.push(["init", { webKey: "YOUR_WEBKEY", }]); ``` -------------------------------- ### Get Segments API Example Source: https://docs.wonderpush.com/reference/get-segments This cURL command retrieves a list of segments for your application. Replace YOUR_APPLICATION_ACCESS_TOKEN with your actual access token. ```curl curl -XGET "https://management-api.wonderpush.com/v1/segments?accessToken=YOUR_APPLICATION_ACCESS_TOKEN" ``` -------------------------------- ### Get All Attached Tags Source: https://docs.wonderpush.com/docs/flutter-sdk Retrieve all tags currently attached to the installation. The result is returned as a promise resolving to an array of strings. ```Flutter / Dart var tags = await WonderPush.getTags(); print("User tags: $tags"); ``` -------------------------------- ### Add WonderPush HCM Flutter Dependency Source: https://docs.wonderpush.com/docs/huawei-mobile-services-hms-push-notification-support Add the wonderpush_hcm_flutter dependency to your pubspec.yaml file and run 'flutter pub get' to install it. ```yaml dependencies: wonderpush_hcm_flutter: ^1.0.2 ``` -------------------------------- ### Get a Segment - cURL Example Source: https://docs.wonderpush.com/reference/get-segments-segmentid Use this cURL command to retrieve details of a specific segment by its ID. Replace 'YOUR_APPLICATION_ACCESS_TOKEN' with your actual access token. ```curl curl -XGET "https://management-api.wonderpush.com/v1/segments/01aty6boilx1jqo3?accessToken=YOUR_APPLICATION_ACCESS_TOKEN" ``` -------------------------------- ### Installation Properties API Source: https://docs.wonderpush.com/docs/ios-sdk APIs for managing installation-specific properties. ```APIDOC ## PUT /properties ### Description Updates the properties of the current installation. Omitting a previously set property leaves it untouched. To remove a property, you must pass it explicitly with a value of `NSNull`. ### Method PUT ### Endpoint /properties ### Parameters #### Request Body - **properties** (NSDictionary) - Required - Properties to add or update. See [format of property names](https://docs.wonderpush.com/docs/properties#property-names) for detailed syntax. ### Request Example ```json { "properties": { "int_age": 34 } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Properties updated successfully." } ``` ``` ```APIDOC ## GET /properties ### Description Returns an `NSDictionary` containing the properties of the current installation. ### Method GET ### Endpoint /properties ### Response #### Success Response (200) - **properties** (NSDictionary) - A dictionary containing the installation properties. #### Response Example ```json { "properties": { "string_name": "John Doe", "int_age": 34 } } ``` ``` -------------------------------- ### Get User ID Source: https://docs.wonderpush.com/docs/cordova-sdk Retrieves the currently assigned user ID for the installation. The callback receives the user ID as a string or null if none is set. ```javascript WonderPush.getUserId(function(userId) { console.log("User ID:", userId); }); ``` -------------------------------- ### Get All Property Values Source: https://docs.wonderpush.com/docs/website-sdk-reference Retrieves all values of a specific property for the current installation as an array. Handles scalar values by wrapping them in an array. Returns an empty array if the property is absent. ```javascript window.WonderPush = window.WonderPush || []; WonderPush.push(function() { WonderPush.getPropertyValues("string_favorityPlayers").then(function(favoritePlayers) { // Use the favoritePlayers array }); }); ``` -------------------------------- ### Initialize CocoaPods Source: https://docs.wonderpush.com/docs/cocoapods-integration Run this command in your project's root directory if a Podfile does not exist to initialize CocoaPods. ```bash pod init ```