ti-howtos
Titanium SDK how-tos
Hands-on guide to Titanium SDK native integrations. Focuses on practical steps, platform differences, and the details that usually bite.
Project detection
::::info Auto-detects Titanium projects This skill detects Titanium projects automatically.
Indicators:
tiapp.xmlexists (definitive)- Alloy project:
app/folder - Classic project:
Resources/folder
Behavior:
- Titanium detected: provide native integration guidance, permissions, modules, and platform notes
- Not detected: say this skill is for Titanium projects only ::::
Integration workflow
- Requirement check: permissions,
tiapp.xml, and module dependencies. - Service setup: listeners and services (Location, Push, Core Motion, and so on).
- Lifecycle sync: tie listeners to Android and iOS lifecycle events.
- Error handling: use robust callbacks for async native calls.
- Platform optimization: apply platform-specific logic (Intent filters, Spotlight, Core Motion).
Native integration rules
iOS permissions
- Location:
NSLocationWhenInUseUsageDescriptionorNSLocationAlwaysAndWhenInUseUsageDescriptionintiapp.xml. - Motion activity: required for Core Motion Activity API.
- Camera and photo:
NSCameraUsageDescriptionandNSPhotoLibraryUsageDescription. - Background modes: required for background audio, location, or VOIP.
- iOS 17+: add
PrivacyInfo.xcprivacyfor UserDefaults and File Timestamps.
Android resource management
- Services: stop background services when they are no longer needed.
- Location: use
distanceFilterand FusedLocationProvider (requiresti.playservices). - Intents: set action, data type, and category. Copy the root activity to
tiapp.xmlfor intent filters.
Data and networking
- HTTPClient: handle both
onloadandonerror. - SQLite: close both
dbandresultSetto avoid locks. - Filesystem: check
isExternalStoragePresent()before using SD card storage. - Binary data: use
Ti.BufferandTi.Codecfor byte-level work. - Streams: use
BufferStream,FileStream, orBlobStreamfor chunked I/O.
Media and memory
- Camera and gallery: use
imageAsResizedto reduce memory pressure. - Audio: handle
pauseandresumefor streaming interruptions. - WebView: avoid TableView embedding; set
touchEnabled=falseif needed. - Video: Android requires fullscreen; iOS supports embedded players.
Platform-specific properties
::::danger Platform-specific properties need modifiers
Using Ti.UI.iOS.* or Ti.UI.Android.* without platform modifiers can break cross-platform builds.
Bad example:
// Wrong: adds Ti.UI.iOS to Android build
const win = Ti.UI.createWindow({
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
});
Good options:
TSS modifier (Alloy):
"#mainWindow[platform=ios]": {
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
}
Conditional code:
if (OS_IOS) {
$.mainWindow.statusBarStyle = Ti.UI.iOS.StatusBar.LIGHT_CONTENT;
}
Always require modifiers:
- iOS:
statusBarStyle,modalStyle,modalTransitionStyle, anyTi.UI.iOS.*. - Android:
actionBarconfig, anyTi.UI.Android.*constant.
For TSS platform modifiers, see the code conventions in skills/ti-expert/references/code-conventions.md#platform--device-modifiers or the platform UI guides in references/ios-platform-deep-dives.md.
::::
Reference guides
Core features
- Location and maps: GPS tracking and battery-efficient location rules.
- Google Maps v2 (Android): API keys, Google Play Services, and v2 features.
- iOS Map Kit: 3D camera, system buttons, and iOS callouts.
- Notification services: push notifications (APNs/FCM), local alerts, interactive notifications.
Data handling
- Remote data sources: HTTPClient lifecycle, JSON/XML parsing, uploads, downloads, sockets, SOAP, SSL.
- Local data sources: filesystem operations, SQLite, Properties API, persistence strategy.
- Buffer, Codec, and Streams: binary data manipulation and serial data flows.
Media and content
- Media APIs: audio playback and recording, video streaming, camera and gallery, ImageViews, density assets.
Web integration
- Web content integration: WebView (WKWebView), local and remote content, bidirectional communication.
- Webpack build pipeline: Ti 9.1.0+ build pipeline, npm integration, and the
@alias.
Platform-specific (Android)
- Android platform deep dives: intents, intent filters, broadcast permissions, background services.
Platform-specific (iOS)
- iOS platform deep dives: iOS 17 privacy, silent push, Spotlight, Handoff, iCloud, Core Motion, WatchKit and Siri.
Advanced and DevOps
- Extending Titanium: Hyperloop, native modules (Proxy and View), Xcode debugging, AndroidX migration for SDK 9.0.
- Debugging and profiling: memory management, leak detection, native tools.
- Automation (Fastlane and Appium): CI/CD, UI testing, store deployment.
Related skills
For tasks beyond native feature integration, use:
| Task | Use this skill |
|---|---|
| Project architecture, services, memory cleanup | ti-expert |
| UI layouts, ListViews, gestures, animations | ti-ui |
| Hyperloop, app distribution, tiapp.xml config | ti-guides |
| Alloy MVC, models, data binding | alloy-guides |
Response format
- Prerequisites: required permissions,
tiapp.xmlconfig, or modules. - Step-by-step implementation: task-focused code guide with error handling.
- Platform caveats: iOS and Android differences.
- Best practices: memory, lifecycle, and performance tips.
More from maccesar/titools
ti-ui
Titanium SDK UI/UX patterns and components expert. Use when working with, reviewing, analyzing, or examining Titanium layouts, ListView/TableView performance optimization, event handling and bubbling, gestures (swipe, pinch), animations, accessibility (VoiceOver/TalkBack), orientation changes, custom fonts/icons, app icons/splash screens, or platform-specific UI (Action Bar, Navigation Bar).
4alloy-guides
Titanium Alloy MVC official framework reference. Use when working with, reviewing, analyzing, or examining Alloy models, views, controllers, Backbone.js data binding, TSS styling, widgets, Alloy CLI, sync adapters, migrations, or MVC compilation. Explains how Backbone.js models and collections work in Alloy.
4