Getting Started

This is a developers’ guide for setting up the Airship SDK for Titanium apps.

The Airship Titanium module allows a developer to integrate push notification services with Titanium apps targeting both Android and iOS. This plugin is designed to be cross-platform, and applications making use of it can leverage the same code on both platforms.

Resources

Requirements

iOS

  • Xcode 11+
  • minimum deployment target iOS 11+

Android

  • minSdkVersion 16+
  • compileSdkVersion 28+

Setup

Start by downloading the latest iOS and Android modules. Modify the tiapp.xml file to include and configure the Airship module.

Configure Airship

Example tiapp.xml
<ti:app>
    ...

    <modules>
       ...

       <module platform="android">ti.airship</module>
       <module platform="iphone">ti.airship</module>
    </modules>


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

    <!-- Production credentials -->
    <property name="com.urbanairship.production_app_key" type="string">Your Production App Key</property>
    <property name="com.urbanairship.production_app_secret" type="string">Your Production App Secret</property>

    <!-- Development credentials -->
    <property name="com.urbanairship.development_app_key" type="string">Your Development App Key</property>
    <property name="com.urbanairship.development_app_secret" type="string">Your Development App Secret</property>

    <!-- Selects between production vs development credentials -->
    <property name="com.urbanairship.in_production" type="bool">false</property>

    <!-- Android -->
    <property name="com.urbanairship.notification_icon" type="string">Name of an icon in /project_name/platform/android/res/drawable folders, e.g. ic_notification.png</property>
    <property name="com.urbanairship.notification_accent_color" type="string">Notification accent color, e.g. #ff0000</property>

    <!-- iOS alert foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_alert" type="bool">true | false</property>
    <!-- iOS badge foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_badge" type="bool">true | false</property>
    <!-- iOS sound foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_sound" type="bool">true | false</property>

</ti:app>

Android FCM

Android requires the google-services.json file to be copied into the app’s directory platform/android/google-services.json.

Import Airship

var Airship = require('ti.airship')

Send Your First Push Notification

At this point in the guide, if you followed all the steps above you should be ready to send a test push notification to verify everything is set up properly.

Before sending a push, you must enable user notifications. The module does not enable user notifications by default in order to avoid prompting the user for permissions. But for a testing purposes, you can enable user notifications as soon as the application is ready. You may also want to set default foreground presentation options to display the notification in the foreground on iOS 10. On older iOS devices, make sure you background the app before sending the push.

Enable user notifications
var Airship = require('ti.airship')

Airship.userNotificationsEnabled = true