Getting Started

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

The Urban 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

Setup

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

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

    <modules>
       ...

       <module platform="android">com.urbanairship</module>
       <module platform="iphone">com.urbanairship</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.gcm_sender" type="String">GCM Sender ID or Project Number</property>
    <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 10 alert foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_alert" type="bool">true | false</property>
    <!-- iOS 10 badge foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_badge" type="bool">true | false</property>
    <!-- iOS 10 sound foreground notification presentation option -->
    <property name="com.urbanairship.ios_foreground_notification_presentation_sound" type="bool">true | false</property>

</ti:app>
Import the module
var UrbanAirship = require('com.urbanairship')

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 UrbanAirship = require('com.urbanairship')

UrbanAirship.setUserNotificationsEnabled(true)