Skip to content

Instantly share code, notes, and snippets.

@csemrm
Created December 4, 2015 13:17
Show Gist options
  • Save csemrm/f2dd5211e37559122fc4 to your computer and use it in GitHub Desktop.
Save csemrm/f2dd5211e37559122fc4 to your computer and use it in GitHub Desktop.
var win = Titanium.UI.createWindow({
title : 'Audio Test',
backgroundColor : '#fff',
//layout : 'vertical'
});
var url = encodeURIComponent("https://itunes.apple.com/us/app/smartuaq/id1063110068?ls=1&mt=8").replace(/'/g,"%27").replace(/"/g,"%22");
var whatsappUrl = 'whatsapp://send?text=' + url;
var clickme = Ti.UI.createButton({
title : 'Click Me',
});
// Listen for click events.
clickme.addEventListener('click', function() {
if (Ti.Platform.osname !== 'android') {
if (Ti.Platform.canOpenURL(whatsappUrl)) {
Ti.Platform.openURL(whatsappUrl);
} else {
Ti.Platform.openURL("https://itunes.apple.com/ae/app/whatsapp-messenger/id310633997?mt=8");
}
} else {
var isSuccess = Ti.Platform.openURL(whatsappUrl);
if (!isSuccess) {
Ti.Platform.openURL("https://play.google.com/store/apps/details?id=com.whatsapp&hl=en");
}
}
});
// Add to the parent view.
win.add(clickme);
win.open();
<ios>
<plist>
<dict>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIRequiresPersistentWiFi</key>
<false/>
<key>UIPrerenderedIcon</key>
<false/>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>whatsapp</string>
</array>
</dict>
</plist>
</ios>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment