WebToNative
  • Getting started
  • Plugin Setup
    • OneSignal Set Up
    • Google AdMob Setup
    • In App Purchase - iOS Setup
    • In App Purchase - Android Setup
    • Firebase Notification Integration - iOS Setup
  • Social Login Integrations
    • Getting the SHA Key for Google Login
    • Create Google OAuth Client Id
    • Facebook Login Configuration
  • Javascript APIS
    • Getting Started
    • Status Bar
    • Pull To Refresh
    • Close App
    • Device Info
    • Clear App Cache
    • OneSignal Push Notification
    • Download Files
    • Printing Options
    • AdMob
    • Geo Location
    • Load In External Browser
    • Barcode Scan
    • In App Purchase - iOS Integration
    • In App Purchase - Android Integration
    • Social Login
    • Facebook App Events
    • Bottom Navigation
    • Clipboard
    • Screen Control
    • Background Location
    • Native Contacts
    • iOS App Tracking Transparency
    • Google Firebase Analytics
    • Haptic Feedback
    • Google Firebase Notification
    • Apps Flyer
    • App Review
    • Calender - iOS
    • Calendar - Android
    • Biometric Authentication
    • Media Player
    • Notification View
    • Offer Card
    • Cookie Update
    • App Launch Detection
    • Download Manager
    • Dynamic App Icon
    • File Sharing
  • Website Plugins
    • Wordpress
      • Push notification (WooCommerce)
      • In-App Purchase
        • In-App Purchase (IAP) Configuration Guide for iOS and Android
        • In-App Purchase (WooCommerce)
        • In-App Purchase
      • Offercard
      • Biometric Authentication
      • Social Login
      • Webtonative media player
        • WebToNative Radio Player
        • MediaPlayer Native Control
    • Bubble.io
      • Customize Status Bar
      • Device-Based Element Visibility
      • Pull to Refresh (Android)
      • OneSignal Push Notification
        • Set External ID
        • Send Push Notification
        • Set/Remove Email or SMS Phone
        • Set Tag
      • Close App
      • Get Device Info
      • Clear App Cache (Android)
      • Screen Control
      • Facebook Events
        • Regular
        • Purchase
      • AdMob
      • Offercard
      • In-App Purchase
        • In-App Purchase (Android/iOS)
        • Get IAP Canceled Subscription List (iOS)
      • Social Login
      • Biometric Authentication
  • Shopify
    • Social Login
    • In-App Purchase
      • In-app purchase
    • Push Notification
      • Abandoned Cart
    • Status Bar Customization
    • Native Device Visibilty
    • Set Onesignal Tags
    • Pull to Refresh
    • Account Deletion
    • Biometric Authentication
  • Upload Apps
    • Android App
    • Ios App
Powered by GitBook
On this page
  • Setting Email and SMS Numbers
  • OptIn and OptOut Functions

Was this helpful?

  1. Javascript APIS

OneSignal Push Notification

You'll need to import the javascript file in your website before starting from this .

getPlayerId: It returns playerId from OneSignal - that can be used to send custom notification from OneSignalApis.

const { getPlayerId } = WTN.OneSignal;

getPlayerId().then(function(playerId){
  if(playerId){
    // handle for playerId
    console.log(playerId)
  }
});
import { getPlayerId } from "webtonative/OneSignal";

getPlayerId().then(function(playerId){
  if(playerId){
    // handle for playerId
    console.log(playerId)
  }
});

setExternalUserId: To set unique user Id to OneSignal.

const { setExternalUserId } = WTN.OneSignal;

setExternalUserId("#$%jfnkjf");
import { setExternalUserId } from "webtonative/OneSignal";

setExternalUserId("#$%jfnkjf");

removeExternalUserId: To remove externalUserId

const { removeExternalUserId } = WTN.OneSignal;

removeExternalUserId();
import { removeExternalUserId } from "webtonative/OneSignal";

removeExternalUserId();

setTags: To add custom data attributes to your OneSignal Users

const { setTags } = WTN.OneSignal;

setTags({
  tags:{
    type:'PREMIUM'
  }
});
import { setTags } from "webtonative/OneSignal";

setTags({
  tags:{
    type:'PREMIUM'
  }
});

addTrigger

const { addTrigger } = WTN.OneSignal;

addTrigger({
    key: "Trigger Key",
    value: "Trigger Value"
});
import { addTrigger } from "webtonative/OneSignal";

addTrigger({
    key: "Trigger Key",
    value: "Trigger Value"
});

addTriggers

const { addTriggers } = WTN.OneSignal;

addTriggers({
    triggers: [
        {
            key: "Trigger Key 1",
            value: "Trigger Value 1"
        },
        {
            key: "Trigger Key 2",
            value: "Trigger Value 2"
        }
    ]
});
import { addTriggers } from "webtonative/OneSignal";

addTriggers({
    triggers: [
        {
            key: "Trigger Key 1",
            value: "Trigger Value 1"
        },
        {
            key: "Trigger Key 2",
            value: "Trigger Value 2"
        }
    ]
});

removeTrigger

const { removeTrigger } = WTN.OneSignal;

removeTrigger({
    key: "Trigger Key"
});
import { removeTrigger } from "webtonative/OneSignal";

removeTrigger({
    key: "Trigger Key"
});

removeTriggers

const { removeTriggers } = WTN.OneSignal;

removeTriggers({
    keys: [ "Trigger Key 1" , "Trigger Key 2" ]
});
import { removeTriggers } from "webtonative/OneSignal";

removeTriggers({
    keys: [ "Trigger Key 1" , "Trigger Key 2" ]
});

getTriggerValue - depricated

const { getTriggerValue } = WTN.OneSignal;

getTriggerValue({
    key: "Trigger Key",
    callback: function(data){
        if(data.isSuccess){
            //data.value contains trigger value for corresponding key
        }
    }
});
import { getTriggerValue } from "webtonative/OneSignal";

getTriggerValue({
    key: "Trigger Key",
    callback: function(data){
        if(data.isSuccess){
            //data.value contains trigger value for corresponding key
        }
    }
});

getTriggers - depricated

const { getTriggers } = WTN.OneSignal;

getTriggers({
    callback:function(data){
        if(data.isSuccess){
            //data.triggers contains list of active trigger
            /*
                e.g.     
                {
                    key: "Trigger Key 1",
                    value: "Trigger Value 1"
                },
                {
                    key: "Trigger Key 2",
                    value: "Trigger Value 2"
                }
            /*
        }
    }
});
import { getTriggers } from "webtonative/OneSignal";

getTriggers({
    callback:function(data){
        if(data.isSuccess){
            //data.triggers contains list of active trigger
            /*
                e.g.     
                {
                    key: "Trigger Key 1",
                    value: "Trigger Value 1"
                },
                {
                    key: "Trigger Key 2",
                    value: "Trigger Value 2"
                }
            /*
        }
    }
});

Setting Email and SMS Numbers

Feature released on 12/06/2023

Available only on Android

Setting and Logging Out Email

const { setEmail, logoutEmail } = WTN.OneSignal;

setEmail({
    emailId:"abc@xyz.com"
});

logoutEmail({
    emailId:"abc@xyz.com"
});
import { setEmail, logoutEmail } from "webtonative/OneSignal";

setEmail({
    emailId:"abc@xyz.com"
});

logoutEmail();

Setting and Logging Out SMS Number

const { setEmail, logoutEmail } = WTN.OneSignal;

setSMSNumber({
    smsNumber:"+911234567890"
});
//Pass Mobile Number with ISD Code

logoutSMSNumber({
    smsNumber:"+911234567890"
}); 
import { setSMSNumber, logoutSMSNumber } from "webtonative/OneSignal";

setSMSNumber({
    smsNumber:"+911234567890"
});
//Pass Mobile Number with ISD Code

logoutSMSNumber();
  • Changes done on 26th June, 2024 for Android targetSdk 34. Now for logout the email and number is mandatory for the required functions.

OptIn and OptOut Functions

Feature added on 06/12/2024

This can be used to manually optin and optout users from OnrSignal.

const { optInUser, optOutUser } = WTN.OneSignal;

optInUser();

optOutUser();

import { optInUser, optOutUser } from "webtonative/OneSignal";

optInUser();

optOutUser();

PreviousClear App CacheNextDownload Files

Last updated 5 months ago

Was this helpful?

Triggers:

https://documentation.onesignal.com/docs/iam-triggers