Last active
December 14, 2015 22:59
-
-
Save skypanther/5162465 to your computer and use it in GitHub Desktop.
Custom URL Schemes: Tap a button in the "Source" app and have it open "Target" Works in iOS and Android. For the Target app's manifest, you'll need to create a PROJECT_DIR/platform/android folder and put the file in there. This is an Alloy-based demo, tested on Titanium 3.0.0.GA.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doClick(e) { | |
if(OS_IOS) { | |
if(Ti.Platform.canOpenURL('Urlschemes://')) { | |
Ti.Platform.openURL('Urlschemes://'); | |
} else { | |
alert('You must install the Urlschemes app first'); | |
} | |
} else { | |
var didItWork = Ti.Platform.openURL('urlschemes://'); | |
if(!didItWork) { | |
alert('You need to install the URLSchemes app'); | |
// in a live app, you'd want to provide a link to or open the Market | |
// such as Ti.Platform.openURL('market://details?id=com.company.yourapp'); | |
} | |
} | |
} | |
$.index.open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window class="container"> | |
<Button id="btn_launchit" onClick="doClick">Open URLSchemes App</Button> | |
</Window> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.appcelerator.urlschemes" android:versionCode="1" | |
android:versionName="1"> | |
<uses-sdk android:minSdkVersion="8" /> | |
<!-- TI_MANIFEST --> | |
<application android:icon="@drawable/appicon" | |
android:label="URLSchemes" android:name="UrlschemesApplication" | |
android:debuggable="false"> | |
<!-- TI_APPLICATION --> | |
<activity android:name=".UrlschemesActivity" | |
android:label="URLSchemes" android:theme="@style/Theme.Titanium" | |
android:configChanges="keyboardHidden|orientation"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW"/> | |
<category android:name="android.intent.category.DEFAULT"/> | |
<category android:name="android.intent.category.BROWSABLE"/> | |
<data android:scheme="urlschemes" android:host=""/> | |
</intent-filter> | |
</activity> | |
<activity android:name="org.appcelerator.titanium.TiActivity" | |
android:configChanges="keyboardHidden|orientation" /> | |
<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" | |
android:configChanges="keyboardHidden|orientation" | |
android:theme="@android:style/Theme.Translucent" /> | |
<activity android:name="org.appcelerator.titanium.TiModalActivity" | |
android:configChanges="keyboardHidden|orientation" | |
android:theme="@android:style/Theme.Translucent" /> | |
<activity android:name="ti.modules.titanium.ui.TiTabActivity" | |
android:configChanges="keyboardHidden|orientation" /> | |
<activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" /> | |
<service android:name="org.appcelerator.titanium.analytics.TiAnalyticsService" | |
android:exported="false" /> | |
</application> | |
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
</manifest> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment