CoolMonster
CoolMonster

Reputation: 2267

Titanium Ti.Android Undefined in ios

I am very new to Titanium Developer. I assigned an Titanium project for made UI changes to latest ios look and feel. When I run App I will always throwh exception like Ti.Android is undefined.

The previous version of the SDK is 3.0.2 but I am now configured the latest version 3.2.3GA

Current the app run without any error in Android only show error as undefined for Ti.Android in Ios only.

My Dough whether Ti.Android is strict to Android platform only or its for both ios and android or else its is deprecated for ios in latest version.

Please help.

Upvotes: 0

Views: 202

Answers (2)

wonu wns
wonu wns

Reputation: 3608

You should check the platform first before using any platform-specific modules/function. You could add a function on your commonjs to check it.

var osname = Ti.Platform.osname;    

function isAndroid() {
    return osname === 'android';
}

function isIOS() {
    return osname === 'iphone' || osname === 'ipad';
}

function isMobileWeb() {
    return osname === "mobileweb";
}

On your controller, you then do something like this:

var fn = require('commonjs');

if (fn.isAndroid()) {
    //the things you do for android only
} else if (fn.isIOS() {

} else if (fn.isMobileWeb()) {

}

Upvotes: 1

0101
0101

Reputation: 2712

As is mentioned in the docs Ti.Android is available only for Android (Ti > 1.5, see the logo on the right) http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android however if you try to access only Ti.Android it should work and return undefined because Ti has no Android property. You shouldn't see any errors... ,but you are probably trying to access some other property for instance Ti.Android.XXX which obviously can't work.

Upvotes: 1

Related Questions