Monday, 2 February 2015

How will you seperate your code on basis of plateform ?

Before we get into the strategies you should adopt, let's look at the mechanics of handling cross-platform coding within Titanium. This includes:
  • Platform identification
  • Recognizing platform-specific APIs and properties
  • Handling platform-specific resources


Platform identification

Titanium provides platform-identification properties in the Ti.Platform namespace that you can use for conditional branching within your code. These are:
Property
Description
Sample values
Ti.Platform.name
Returns the name of the platform returned by the device
iPhone OS for iPhone or iPod, android for Android, returns thenavigator.userAgent string on Mobile Web
Ti.Platform.osname
Returns an abbreviated identifier of the platform
iphone for iPhone or iPod, ipad for iPad, android for Android, andmobileweb on Mobile Web
Ti.Platform.model
Returns device model identifier
iPhone 3GS or iPod Touch 2G or Droid (unsupported on Mobile Web)
http://docs.appcelerator.com/titanium/3.0/#!/guide/Supporting_Multiple_Platforms_in_a_Single_Codebase

No comments:

Post a Comment