1
votes

Titanium SDK version: 1.8.0.1

iPhone SDK version: 4.3

I am building an iOS app using Appcelerator. I try to setup push notifcations for Urban Airship using the official Appcelerator wiki guide: https://wiki.appcelerator.org/display/guides/Push+Notifications+with+Urban+Airship.

First I include the urbanairship.js file into the app.js file.

Ti.include('urbanairship.js');

Then I add these for lines (I replaced my tokens with XXX):

UrbanAirship.key='XXX';
UrbanAirship.secret ='XXX';
UrbanAirship.master_secret='XXX';
UrbanAirship.baseurl = 'https://go.urbanairship.com';

When I run the app in the simulator I get this error:

Script Error = Can't find variable: UrbanAirship at app.js (line 9).

What am I missing?

1
Cross-link to Appcelerator site: developer.appcelerator.com/question/131597/… - Peter K.

1 Answers

0
votes

For anyone stumbling on this one,

You need to declare the variable 'UrbanAirship' before trying to assign values like key, secret, etc.

something like

var UrbanAirship = require('ti.urbanairship');

before typing in

UrbanAirship.key='XXX';
UrbanAirship.secret ='XXX';
UrbanAirship.master_secret='XXX';
UrbanAirship.baseurl = 'https://go.urbanairship.com';

The error message is quite straightforward. The system cannot find the variable because it is not defined.

PS - I believe 'Ti.include' is best used when trying to include .js files and not for modules.