Getting Started

NativeScript lets JavaScript developers build native mobile apps for iOS and Android. Learn more about installing the Pyze NativeScript Smart SDK, initializing it, using events, and setting up In-app and/or push notifications. The Pyze SDK supports Android versions 4.0.3 (minSdkVersion 15) and above for Android and iOS version 8 or above for iOS.

1. Get one or more Pyze App Keys

See instructions to get one or more Pyze App Keys depending on platforms (iOS and/or Android) you support for your NativeScript app.

2. Install the Pyze SDK

Install the Pyze NativeScript package

3. Setup & Initialize

Setup & Initialize Pyze in your NativeScript app

Build and Go!

You have enabled all screen flow funnels, loyalty, cohort and churn analysis, Intelligence data explorations, built-in events, auto segmentation, and much more. Use your app with the Pyze SDK and you should see data on

In the following sections, you can add app-defined-, timed- and curated- events. To reach out to your users and create meaningful relationships, add push and in-app notifications.

4. Add events

Add Events to your NativeScript app.

A comprehensive overview of curated, app defined, timed and built-in events is available under Events in the api & events.

5. Build meaningful relationships with your users

Pyze delivers intelligence-driven marketing and growth automation, so you can build meaningful relationships with your users.

App SDK API, Samples, Resources for NativeScript developers

NativeScript API

Setup & Initialize

Get Pyze App Keys

Get a Pyze App Key (PAK) for iOS and Android NativeScript apps from

1. Login to

Every app is uniquely assigned a Pyze App Key (PAK), a 22 character app specific key, which you obtain from after logging in with your email and password. If you have not signed up for Pyze, you can Get Pyze here first.

Login to

2. Add a new app

  • To add an application to the Pyze platform, begin by selecting Settings from the Navigation Pane.
  • Under the Apps Tab, click the Add App+ button at the top right of the window.
  • Enter the App Name and Appstore URL (if available), Platform (iOS, Android, Web/SaaS, tvOS, watchOS) and select your Timezone.

3. Copy Your Pyze App Key

Once you add your new app, refresh the page. Navigate to your newly added app’s settings by selecting the app from the drop-down list. The Pyze App Key will be displayed below to the right (DmPTFdslRjObk1-ZlXQDVQ in this example). Copy Pyze App Key.

Pyze NativeScript App SDK

Getting Started with NativeScript

If you are new to NativeScript, see Getting Started with NativeScript App. Install NativeScript and create an iOS and/or Android app.

Installing Pyze NativeScript SDK

Run the following command inside your project directory.

tns plugin add pyze-nativescript

Now you are ready to Setup and Initialize for iOS and Android

Pyze NativeScript App SDK: Setup & Initialize

The instructions on this page assume you have installed the Pyze SDK into your NativeScript project. If not, Install the SDK and come back to this page. See Getting Started NativeScript Guide

a. Register for the activity lifecycle here

    class CustomAppDelegate extends UIResponder implements UIApplicationDelegate {
            public static ObjCProtocols =[UIApplicationDelegate];
        applicationWillFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary): boolean {
                return true;
    application.ios.delegate = CustomAppDelegate;
    application.start({ moduleName: "main-page" });
    var application = require("application");
    var Pyze = require("pyze-nativescript").Pyze;
    if ( {, function (args) {
    application.start({ moduleName: "main-page" });

b. Alternatively you can specify the log level, using following method

    Pyze.initializeWithLogLevel("PYZE_APP_KEY", "PyzelogLevelAll");

The possible Log Level values are:

  • PyzelogLevelAll
  • PyzelogLevelErrors
  • PyzelogLevelWarnings
  • PyzelogLevelMinimal

Build and Go!


Pyze NativeScript App SDK - Events

See a detailed Events Overview at api & events.

Custom Event Handling

Add the following import statements

import {PyzeEvents} from 'pyze-nativescript';

Add the events of your choice in your code.

  1. Post custom events

     PyzeEvents.postCustomEvent("Custom Event");
  2. Post custom event with attributes

     var customAttributes = {};
     customAttributes["Seconds Played"] = 33.33;
     customAttributes["Bulletes Fired"] = 300;
     customAttributes["Enemy Killed"] = 25;
     PyzeEvents.postCustomEventWithAttributes("Game End", customAttributes);

Curated Event Handling

Pyze has made it easy for you to capture events. We support many built-in events (see API).

For example, to send an Ad requested event, import the curated event class and use it as shown in example below:

import {PyzeAd} from 'pyze-nativescript'; //Import PyzeAd class from the PyzeNativeScript package
var customAttributes = {};
customAttributes["First Name"] = "John";
customAttributes["Last Name"] = "Smith";
customAttributes["Age"] = 25;
    "AdMob",                // AdNetwork
    "Settings",            // App Screen
    "300x50",              // Ad SIze
    "Banner",              // Type

Enable Mobile Marketing

Push Notifications (NativeScript - iOS)

Apple Push Notifications

Apple provides a Apple Push Notification service (APNs) to allow app developers to reach out to their users via push notifications.

The App businesses have the option of hosting and running servers “provider” themselves to send notification content “payload” to Apple over a persistent and secure channel using HTTP/2 multiplex protocol. Apple then forwards the notification content to your app on user’s device.

Pyze customers don’t have to maintain provider servers to communicate with Apple’s push notification service. Pyze can be used to send push notifications for an app in development, an app in production provisioned through the app store, and to a combination of apps in development and production.


You will need access to your Apple developer Account, Xcode development environment, macOS Keychain Access, and finally iTunes Connect to publish your push-notification enabled app.

Using Pyze as your provider for push notifications

In the following sections, we will create APNs SSL certificates, use your Keychain to convert it into a file (.p12) and upload it to We will also create a mobile provisioning file to import into Xcode. Then we will also enable Background Modes in your project using Xcode and write code to register for remote notifications in your app. Finally, we will enable your app with push notifications.

You will be doing a lot of configuring and clicking, but only write 4-5 lines of code.

1. Generate and download APNs SSL certificates
Login into your Apple developer Account
Create or Edit App and enable Push Notifications
  • From Apple developer Account, click on Certificate, Identifiers & Profiles. (Note: “People” resource is available to developers who you enroll as an organization, as opposed to an individual)

  • Under Identifiers group, click on App IDs. If creating a new app, click on the “+” button on top right. Or, if you have already created the app, select the app and click on the Edit button.

  • Get the bundle ID from your app

Enter your App Id Description and suffix (bundle id) and make sure you have enabled Push Notifications. Ensure the bundle ID that you provide matches the bundle ID that you’re using in your app. (This is a common mistake). Click on Continue.

<figure><img class="docimage" src="images/nativescript/register-app-ID.jpg" alt=""  /></figure>

<figure><img class="docimage" src="images/nativescript/bundle-id.jpg" alt=""  /></figure>

<figure><img class="docimage" src="images/nativescript/EnablePush.jpg" alt=""  /></figure>
Generate SSL certificate and download it
  • Once you successfully created the App-ID, select your App-ID and click the Edit button. In the resulting page scroll down to the Apple Push Notification service SSL Certificates section.

  • Click on Create Certificate button for either Development SSL certificate or Production SSL certificate. See Distribution considerations below.

  • You will be presented with instructions for creating a Certificate Signing Request (CSR) in Keychain Access. Do not click on Continue and please read the instructions provided by Apple and/or follow along below.

  • In the Applications folder on your Mac, open the Utilities folder and launch Keychain Access (Or press command-space and type Keychain Access). Within the Keychain Access Utilities App’s drop down menu, select Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.

  • In the Certificate Information window, enter the email address and a name for your private key. Leave CA Email Address field blank. In the “Request is” group, select the “Saved to disk” option. Click Continue and then save at a known location within Keychain Access to complete the CSR generating process.

  • Switch back to the Apple developer Account where you left of and click on Continue. Upload your Certificate Signing Request (CSR) needed to generate certificate.

  • Generate and then download the certificate as a .cer file

2. Generate Personal Information Exchange PKCS #12 (.p12)

Import certificates into Keychain Access and export Personal Information Exchange PKCS #12 (.p12) file

  • Import the certificate (.cer) you created, either by double clicking it or by choosing File > Import items in Keychain Access.

  • Ensure you have selected your certificate from ‘My Certificates’ under left hand side ‘Category’.

  • Select the certificate which you have added choose File > Export items from menu and export the certificate as Personal Information Exchange (.p12) file. While saving the p12, it is always recommended that you create a password. Note down your password, you will need it in the later steps.

3.Create Mobile Provisioning profile to download and import into Xcode

In this we will create a mobile provisioning profile in Apple developer Account, download it and import it into Xcode. The profile contains test devices you can send push notifications to during development.

  • Login into Apple developer Account, click on Certificate, Identifiers & Profiles.<br (Note: “People” resource is available to developers who you enroll as an organization, as opposed to an individual)

  • Select ‘All’ under Provisioning Profiles in Certificates, Identifiers & profiles. Click ‘+’ on top right to create a new profile

  • Depending on type of provisioning profile (development or production provisioning profile), select the right type. Click on Continue. See Distribution considerations below.

  • Select App ID which you have created. Click on Continue.

    Select iOS Development Certificate or iOS Production Certificate which you created and click on Continue.
    Select Devices pane appears, select device(s) which you would to want to test the APNs service and click on Continue
    Enter a profile name for your app, click Continue and Download the certificate and click Done.

    Note, if Certificates don’t exist, you will be prompted to create one.

  • Once you ‘Download’ the mobile provision certificate, import it into Xcode by double clicking downloaded mobile provisioning certificate.

  • Verify time and date of import into xcode, by opening terminal and typing the following. You should see the date time of the latest imports. ls -light ~/Library/MobileDevice/Provisioning\ Profiles

Joes-MacBook-Pro-15:~ awesomejoe$ ls -light ~/Library/MobileDevice/Provisioning\ Profiles
9453527 -rw-r--r-- 1 staff 7.7K Jan 8 15:27 cafebeef-dead-bead-fade-decadeaccede.mobileprovision

4. Configure Pyze as your provider

In order to allow Pyze to send push notifications on your behalf to users of your app, please provide the iOS push certificate to Pyze.

  • Login to
  • Click Settings from the Navigation Pane
  • Select the app you want to provide keys for from the drop down list
  • Select Push Notifications on the left menu
  • Upload a Push notifications certificate in .p12 format, provide p12 password (the password you generated while creating the certificate), and specify the provisioning mode: Development or Production depending on the type of certificate you are using.
  • Select daily and weekly quota limits
  • Click Save

5. Distribution considerations

Before you publish your app to AppStore or make a public Ad Hoc release, ensure you created a Production SSL certificate and used a Distribution mobile provisioning profile when following the steps above.

Also, ensure you have uploaded a Production .p12 certificate following steps mentioned in above section. Use Production Mode for Provisioning Mode.

6. Enable Remote Notifications in Xcode Project

You can either turn Remote Notifications on either from the Xcode UI or by editing the app’s property list (usually Info.plist) file depending on you preference.

Option 1: Using Xcode UI
  • In Xcode, choose View > Navigators > Show Project Navigator, or press ⌘1.
  • Select your target under the TARGET heading and then select the Capabilities tab
  • Open Background Modes, turn on slider to enable Background Modes then turn on Remote Notifications by clicking on the corresponding check mark.
Option 2: Editing app’s property list (usually Info.plist) file directly

Open your Info.plist file and add following lines


7. Enable your app for Push Notifications

Enable push notification and background mode for your application. Then Register for following app delegate methods

  1. applicationDidFinishLaunchingWithOptions
  2. applicationDidRegisterForRemoteNotificationsWithDeviceToken
  3. applicationDidReceiveRemoteNotification
Register For Remote Notifications
  • applicationDidFinishLaunchingWithOptions

    Paste the following code inside the applicationDidFinishLaunchingWithOptions method

     var userNotificationTypes   = (UIUserNotificationTypeAlert
         | UIUserNotificationTypeBadge| UIUserNotificationTypeSound);
                 var userNotificationSettings = UIUserNotificationSettings.settingsForTypesCategories(userNotificationTypes,null);
         return true;        
Let Pyze know the APNS device token
  • applicationDidRegisterForRemoteNotificationsWithDeviceToken

    Paste the following code inside the applicationDidRegisterForRemoteNotificationsWithDeviceToken method.

     -(void) application: (UIApplication *) application
         didRegisterForRemoteNotificationsWithDeviceToken: (NSData *) deviceToken {
             [Pyze setRemoteNotificationDeviceToken:deviceToken];
Let Pyze process Remote Notifications
  • applicationDidReceiveRemoteNotification

    Paste the following code inside the applicationDidReceiveRemoteNotification method.


Push Notifications with FCM

Google Notifications

Google provides the Firebase Cloud Messaging service (FCM) to allow app publishers to reach out to their users via push notifications.

App Publishers have the option of hosting and running servers “app servers” themselves to send notification content “payload” to FCM. Google then forwards the notification content to your app on user’s device.

Pyze customers do not have to maintain their own servers to communicate with Google’s Messaging service. Pyze can be used to send push notifications for an app in development, an app that is live in Google Play, and to a combination of apps in development and production.


You must Create Firebase project in Firebase console. Click here after logging into the google account that owns your project for next steps.

Following sections

In the following sections, we will generate the google-services.json and enter the Server Key in Then we will also enable push notifications in your Android project.

Configuring the Server API Key and Sender ID

In this section we will

  1. Get the Server Key and Sender ID for your app
  2. Enter the Server Key on
Generate the Server API Key and Sender ID
Login into the Google Account that owns your app
Go to Google Cloud Messaging and select Get a Configuration File
  • Obtain the Server API Key and Sender ID from the project settings for your
Enter the Server Key and Sender ID on
Login into your Firebase Console
  1. Select Your Project and Click on the Settings icon next to the Project name
  2. In the Cloud Messagin Tab, locate the Server Key and Sender ID
Login into your Pyze Account
  1. On the Settings page, select an app from the drop down menu.
  2. On the App Settings page, navigate to the Push Notifications settings from the left pane.
  3. Enter the Server key and Sender ID along with quota limits for the maximum number of push messages your app can send in a day and a week.
Integrate FCM Push Notifications in your App project
  1. First, add rules to your root-level build.gradle file, to include the google-services plugin:

     buildscript {
         // ...
         dependencies {
             // ...
             classpath ''
  2. Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:

     apply plugin: ''
     android {
       // ...
     dependencies {
       // ...
       compile ''
     apply plugin: ''
  3. Add the below dependency to your app’s build.gradle file:

     dependencies {
         compile ""
  4. In the Android.Manifest file, add the below between the Application Tag:

     <receiver android:name="" android:exported="true"/>
             <action android:name="" />
  5. Get the configuration file from Google and place it under your app/ folder in your android studio project. Open this link for more info:

In-App Notifications

Enable In-app Notifications in your App

In-app notifications allow app publishers to reach out to app users when they use your app. In-App Notifications are deeply integrated in Pyze Growth Intelligence and allow app publishers to reach out to users from manually from Dynamic Funnels and Intelligence Explorer, and automatically based on workflows and campaigns from Growth Automation.

App publishers have full control over when to display the in-app messages and have two options: use the user interface provided by Pyze or develop their own.

Option 1. Use Pyze provided user interface

Invoke built-in User Interface from your app

You can look for In-App messages and invoke the built-in UI anywhere in your app. For example, on a button click or in your Start method or when new scene is loaded/unloaded.

Invoke UI from your app

  • Call the following method, whenever you want to show notification with default pyze UI. Method accepts a callback handler method which will be invoked whenever any of the call to action button on the UI is pressed.



           PyzeEvents.postCustomEvent("CTA Clicked");
  • Call the following method to customize the look and feel of the In-App Message Navigation Bar buttons, and show Read, Unread or Both messages. Upto twenty previously read messages are cached, so your users can view them using the PyzeInAppMessageType enumerations like PyzeInAppTypeUnread, PyzeInAppTypeRead or PyzeInAppTypeAll .

     showInAppNotificatonWithCustomAttributes(messageType, colour, callback);


     Pyze.showInAppNotificatonWithCustomAttributes(messageType, colour, function(messageDetails){


       ("PyzeInAppTypeAll","#c9c9c9", function(param){
  • Call the following method, whenever you want to get the unread message count from server.

  • To get notified which button the app user clicked on along with the deep link status, implement a handler for the call-to-action buttons.


           if(message.Value > 0){
                 console.log("Button Clicked: " + messageDetails.ButtonId
                         + " Title: " + messageDetails.Title
                         + " Status: " + messageDetails.Status
                         + " Url: " + messageDetails.UrlInfo
                         + " Message Id: " + messageDetails.mId
                         + " Campaign Id: " + messageDetails.cId
  • To close the in app message use the following method



Option 2. Build your own user interface

You can provide your own user interface for in-app messages using the base level APIs

  • Get Count of New and Unfetched In-App Messages

    To get the count of new and un-fetched in-app messages you can call the following method.

  • Get Message Headers

    To get the message headers call the following method. Upto 20 messages are cached within the SDK. Using PyzeInAppMessageType you can fetch new unfetched messages, or previously fetched and cached in-app messages or you can get all messages.

     getMessageHeaderOfType( messageType, callback);

    Use any of the following PyzeInAppMessageType strings “PyzeInAppTypeUnread” , “PyzeInAppTypeRead” or “PyzeInAppTypeAll”

  • Get Message Body

    To get the message body call the following method with details of the messageHeaders

     getMessageWithContentID( contentId,  messageId, callback);
  • Implement handler for button clicks

    To display all unread messages

           if(value > 0 ){
                 //Note for iOS platform below parsing from string headers to JSON is not needed.
           var jsonArray = JSON.parse(headers);
                 jsonArray.forEach(function(element) {
                 }, this);

Sending In-App notifications from

In-app notifications allow app publishers to reach out to app users when they use your app. In-App Notifications are deeply integrated in and allow app publishers to reach out to users from manually from Conversion Funnels and Auto Segmentation, and automatically based on workflows and campaigns from Growth Automation. For illustration purposes, we will send In-App Notifications from Conversion Funnels.

  • Sending In-App notifications from Conversion Funnels

    Create an event sequence and specify filters. You can reach out from either Build & Run or from Saved Funnels.

    Create and send an In-App Notification. In this example, we will congratulate the user for reaching a milestone with a reward.

Enable Personalization

Personalization Intelligence™

Enable Personalization in your App

To learn more about personalization see here.

In Intelligence explorer, for example, you may assign “High Value” tag to users who match the following criteria. This tag will be available in your app to personalize content feed, experience, user interface or messaging.

  • High Engagement and High Loyalty or
  • High Advocacy and Seasonal Ticket Holder or
  • High Revenue or
  • High Engagement, High Advocacy, and Low or Medium Attrition Risk or

The Personalization Intelligence™ tags assigned to a user are available in the agent and are accessible via class PyzePersonalizationIntelligence

The following methods are available in this class


Get all tags assigned to the user.
Note: Tags are case sensitive, High Value and high value are different tags.


isTagSet(tag, callback)

Returns true if requested tag is assigned to user.
Note: Tags are case sensitive, High Value and high value are different tags


PyzePersonalizationIntelligence.isTagSet("loyal", function(tagExists) {
areAnyTagSet(listOfTags, callback)

Returns true if at least one tag is assigned.
Note: Tags are case sensitive, High Value and high value are different tags.


PyzePersonalizationIntelligence.areAnyTagSet(["loyal","High Value","Low value"], function(tagExists) {

Returns true if all tags requested are assigned to user.
Note: Tags are case sensitive, High Value and high value are different tags.


PyzePersonalizationIntelligence.areAllTagSet("loyal,High Value,Low value", function(tagExists) {

User Privacy

Pyze provides APIs to allow end-users to Opt out of Data Collection and also instruct the Pyze system to forget a user’s data.


Allows end-users to opt out from data collection. Opt-out can be toggled true or false.


To resume user data collection set value to false



Allows end-users to opt out from data collection and delete the user in the Pyze system. We recommend you confirm this action as once a user is deleted, this cannot be undone.