Appcelerator Getting Started

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 Appcelerator app.

  • See instructions to for iOS.
  • See instructions to for Android.

2. Install the Appcelerator plugin

3. Setup & Initialize

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 growth.pyze.com.

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

5. Build meaningful relationships with your users

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

Android - Appcelerator

Setup & Initialize

Get Pyze App Keys

Get a Pyze App Key (PAK) for iOS and Android Appcelerator apps from growth.pyze.com.

1. Login to growth.pyze.com

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

Login to growth.pyze.com

2. Add a new app

Click on the Add App button on top right corner and provide the details for your app, including name, platform and optional URL for the app store. Specify the timezone where you are located.

3. Copy Pyze App Key from newly added app

Hover over the newly added app with rotating Pyze logo and copy the Pyze App Key (jUiix5alQ7KYSlG6ZQ_TXw in this example). Alternatively, you click on the “App Profile” icon and copy the PAK from the App profile page.

Alternatively, you click on the “App Profile” icon and copy the PAK from the App profile page.

Pyze Appcelerator plugin

Installing Pyze Appcelerator plugin

  1. Copy the plugin zip inside your project directory

  2. Open tiapp.xml and under modules add the following line

<module version="1.0.0" platform="android">com.pyze.appc</module> 

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

Pyze Appcelerator App Plugin: Setup & Initialize

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

Android

  1. Open tiapp.xml and add the pyze app key as follows
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
         <application>
           <meta-data android:name="PyzeAppKey" android:value="YOUR PYZE APP KEY"/>
         </application>
        </manifest>
     </android>
    
    

    To access Pyze API’s

  2. Import pyze module and get a reference for the module

     var pyze = require('com.pyze.appc');
    
  3. Call the pyze api’s

     pyze.postCustomEventWithAttributes("MY_EVENT",{"A1":"V1","A2":"V2"});
        
    

Build and Go!

Add Events

Pyze Appcelerator App SDK - Events

Add the events of your choice in your code.

pyze.postCustomEvent("Event Name");

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

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-sdk-react-native'; //Import PyzeAd class from the PyzeReact Native package
    ...
    ...
var customAttribute = {};
customAttribute.color = "Red";
PyzeAd.postAdRequested("Google", "home", "(320, 160)", "banner", customAttribute);

Custom Event Handling

We also support custom events in addition to built in events. See custom events class api.

For example, to send a custom “Game End event” use:

import {PyzeEvents} from 'pyze-sdk-react-native'; //Import PyzeEvents class from the PyzeReact Native package

    ...
    ...
var customAttribute = {};
customAttribute.color = "Red";
pyze.postCustomEventWithAttributes("Event Name",customAttribute);

Enable Mobile Marketing

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.

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.

     showInAppNotification(callback);
    

    Usage

     pyze.showInAppNotification(function(params){
                 Ti.API.info("Params" + params);
     })
    
    

    Or 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 .

     void showInAppNotificatonWithCustomAttributes(messageType, colour, callback);
    

    Usage

     pyze.showInAppNotificatonWithCustomAttributes("PyzeInAppTypeAll","#c9c9c9", function(param){
          console.log(param);
     });
    
    
  • Call the following method, whenever you want to close the in app message.

     closeInAppMessage();
    

    Usage

     pyze.closeInAppMessage();
    

Sending In-App notifications from growth.pyze.com

In-app notifications allow app publishers to reach out to app users when they use your app. In-App Notifications are deeply integrated in growth.pyze.com 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. For illustration purposes, we will send In-App Notifications from Dynamic Funnels.

  • Sending In-App notifications from Dynamic Funnels

    Create an event sequence, specify filters. You can reach out from either Dynamic Funnels or from Recent Sequences

    Create and send an In-app Notification. In this example, we will inform users of a tour we created for users

    View progress in Campaign History

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

getTags(callback)

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

Usage

pyze.getTags(function(param){
        console.log(param);
});

isTagSet()

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

areAnyTagSet()

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

areAllTagSet()

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

iOS - Appcelerator

Install & Initialize

Get Pyze App Keys

Get a Pyze App Key (PAK) for iOS and Android Appcelerator apps from growth.pyze.com.

1. Login to growth.pyze.com

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

Login to growth.pyze.com

2. Add a new app

Click on the Add App button on top right corner and provide the details for your app, including name, platform and optional URL for the app store. Specify the timezone where you are located.

3. Copy Pyze App Key from newly added app

Hover over the newly added app with rotating Pyze logo and copy the Pyze App Key (jUiix5alQ7KYSlG6ZQ_TXw in this example). Alternatively, you click on the “App Profile” icon and copy the PAK from the App profile page.

Alternatively, you click on the “App Profile” icon and copy the PAK from the App profile page.

Pyze Appcelerator plugin

Installing Pyze Appcelerator plugin

Open tiapp.xml and under modules add the following line

    <module version="1.0.0" platform="iphone">ti.pyze<module> 

Pyze Appcelerator App Plugin: Setup & Initialize

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

  1. Open tiapp.xml and add the pyze app key as follows
    <ios>
      <plist>
         <dict>
           <key>PYZE_APP_KEY<key>
           <string><YOUR APP KEY><string>
         < dict>
      < plist>
    < ios>

To access Pyze API’s

  1. Import pyze module and get a reference for the module

     var pyze = require('ti.pyze');
    
    

Add Events

Pyze Appcelerator App SDK - Events

Add the events of your choice in your code.

var pyze = require('ti.pyze');
pyze.postCustomEvent("customEventName")

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

Custom Event Handling

We also support custom events in addition to built in events. See custom events class api.

For example, to send a custom event use:

var pyze = require('ti.pyze');
pyze.postCustomEventWithAttributes("customEventName", {"attrrKey1":"attrvalue1", "attrrKey2":"attrvalue2"}

To send a timed event use:

var pyze = require('ti.pyze');
var timerRef = pyze.timerReference
pyze.postCustomEventWithAttributes("customEventName", timerRef, {"attrrKey1":"attrvalue1", "attrrKey2":"attrvalue2"})

Enable Mobile Marketing

Push Notifications using APNS

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.

Prerequisites

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 growth.pyze.com. 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/ios/register-app-ID.jpg" alt=""  /></figure>


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


<figure><img class="docimage" src="images/ios/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 growth.pyze.com
  • Navigate to the app you want to provide keys for
  • Select App Profile page either from the Portfolio page or menu
  • 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.
  • Click Save
  • Select daily and weekly quota limits
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

Open tiapp.xml file and add following lines

<ios>
    <plist>
        <dict>
            <key>UIBackgroundModes</key>
            <array>
                <string>fetch</string>
                <string>remote-notification</string>
            </array>
        </dict>
    </plist>
</ios>

7. Enable your app for Push Notifications
Register For Remote Notifications

See appcelerator guide for push notification here

Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
    Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);
    Ti.Network.registerForPushNotifications({
        success: deviceTokenSuccess,
        error: deviceTokenError,
        callback: receivePush
    });
});

Register notification types to use

 Ti.App.iOS.registerUserNotificationSettings({
    types: [
        Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
        Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
        Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
    ]
});

Let Pyze know the APNS device token

Add following code

function deviceTokenSuccess(e) {
    deviceToken = e.deviceToken;
	
	var pyze = require('ti.pyze');
    pyze.setRemoteNotificationDeviceToken(deviceToken);
}

Let Pyze process Remote Notifications

Add following code

function receivePush(e) {
	 Ti.API.info('receivePush `'+JSON.stringify(e)+'`:');
 
	// alert('Received push: ' + JSON.stringify(e));
	 pyze.processReceivedRemoteNotification(e)
 }

Interactive Notifications

See appcelerator interactive notifications guide here

Pyze provides a set of predefined push notification categories for showing interactive notifications. Below is the list of categories and respective actions:

Yes or No (opens the app)

Category Id : pyze_bool_foreground Actions:

  1. Title: Yes Action Id: yes Foreground: true Authentication Required: true

  2. Title: No Action Id: no Foreground: false Authentication Required: true

Yes or No (dismiss notification)

Category Id : pyze_bool_background Actions:

  1. Title: Yes Action Id: yes Foreground: true Authentication Required: true

  2. Title: No Action Id: no Foreground: false Authentication Required: true

Accept or Decline (opens the app)

Category Id : pyze_accept_action_foreground Actions:

  1. Title: Accept Action Id: accept Foreground: true Authentication Required: true

  2. Title: Decline Action Id: decline Foreground: false Authentication Required: true

Accept or Decline (dismiss notification)

Category Id : pyze_accept_action_background Actions:

  1. Title: Accept Action Id: accept Foreground: false Authentication Required: true

  2. Title: Decline Action Id: decline Foreground: false Authentication Required: true

Shop Now

Category Id : pyze_shop_now Actions:

  1. Title: Shop Now Action Id: shop_now Foreground: true Authentication Required: true

Buy Now

Category Id : pyze_buy_now Actions:

  1. Title: Buy Now Action Id: buy_now Foreground: true Authentication Required: true

Follow

Category Id : pyze_buy_now Actions:

  1. Title: Follow Action Id: follow Foreground: false Authentication Required: true

Opt-In

Category Id : pyze_opt_in Actions:

  1. Title: Opt-In Action Id: opt_in Foreground: false Authentication Required: true

Unfollow

Category Id : pyze_unfollow Actions:

  1. Title: Unfollow Action Id: unfollow Foreground: false Authentication Required: true

Opt-out

Category Id : pyze_opt_out Actions:

  1. Title: Opt-out Action Id: opt_out Foreground: false Authentication Required: true

Remind Me Later

Category Id : pyze_remind_me_later Actions:

  1. Title: Remind Me Later Action Id: opt_out Foreground: false Authentication Required: true

Download

Category Id : pyze_download Actions:

  1. Title: Download Action Id: download Foreground: true Authentication Required: true

Share

Category Id : pyze_share Actions:

  1. Title: Share Action Id: share Foreground: true Authentication Required: true

Download / Share

Category Id : pyze_download_share Actions:

  1. Title: Download Action Id: download Foreground: true Authentication Required: true

  2. Title: Share Action Id: share Foreground: true Authentication Required: true

Remind Me Later / Share

Category Id : pyze_remind_share Actions:

  1. Title: Remind Me Later Action Id: remind Foreground: false Authentication Required: true

  2. Title: Share Action Id: share Foreground: true Authentication Required: true

Defining a notification category

Ex. Category, Accept or Decline (opens the app) can be defined as below

var acceptAction = Ti.App.iOS.createUserNotificationAction({
    identifier: “accept”,
    title: “Accept”,
    activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND,
    destructive: false,
    authenticationRequired: true
});
var rejectAction = Ti.App.iOS.createUserNotificationAction({
    identifier: “decline”,
    title: “Decline”,
    activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
    destructive: true,
    authenticationRequired: true
});
var acceptDeclineCategory = Ti.App.iOS.createUserNotificationCategory({
    identifier: "pyze_accept_action_foreground",
    actionsForDefaultContext: [acceptAction, rejectAction],
    actionsForMinimalContext: [acceptAction, rejectAction]
});

Like notification types, register defined notification categories by using the Titanium.App.iOS.registerUserNotificationSettings() as below:

Ti.App.iOS.registerUserNotificationSettings({
    types: [
        Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
        Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
        Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
    ],
    categories: [acceptDeclineCategory]
});

Monitor Interactive Notifications

Let pyze process the notification received and perform selected push action:

Ti.App.iOS.addEventListener('remotenotificationaction', function(e) {
    Ti.API.info('remotenotificationaction `'+JSON.stringify(e)+'`:');
        pyze.handlePushNotificationAction(e.identifier, e);
    });
}

Rich Notifications

Open the .xcodeproj and follow the instruction in below link in-order to integrate rich push notifications

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.

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 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 .

     void showInAppNotificationUIForDisplayMessagesWithCustomAttributes(messageType, buttonTextcolor, buttonBackgroundColor, backgroundColor, messageCounterTextColor, callback);
       
    

    Usage

     var pyze = require('ti.pyze');
         pyze.showInAppNotificationUIForDisplayMessagesWithCustomAttributes(0, "#ffffff", "#ffffff", "#ffffff", "#ffffff", function(params){ 
         var status = params[0]
         Ti.API.info('InAppStatus  `'+params[0]+'`:');
         });
    
    
  • Call the following method, whenever you want to close the in app message.

     dismissInAppNotificationUI();
    

    Usage

     var pyze = require('ti.pyze');
     var appInstanceId = pyze.dismissInAppNotificationUI():
    
    

Sending In-App notifications from growth.pyze.com

In-app notifications allow app publishers to reach out to app users when they use your app. In-App Notifications are deeply integrated in growth.pyze.com 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. For illustration purposes, we will send In-App Notifications from Dynamic Funnels.

  • Sending In-App notifications from Dynamic Funnels

    Create an event sequence, specify filters. You can reach out from either Dynamic Funnels or from Recent Sequences

    Create and send an In-app Notification. In this example, we will inform users of a tour we created for users

    View progress in Campaign History

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