Created
November 22, 2011 02:24
-
-
Save jonalter/1384711 to your computer and use it in GitHub Desktop.
iOS: launch your app from another app
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
// info.plist from Test 5 | |
// Open your info.plist and look for CFBundleURLSchemes | |
// this is the string that you will use to open that app | |
// You can also copy the info.plist to the root of your app and edit it. | |
// You can even have multiple schemes that you can use to launch it. | |
// Here I can launch the app using either 'test5://' or 'pedro://' | |
// Be SURE to do a clean build | |
<key>CFBundleURLSchemes</key> | |
<array> | |
<string>test5</string> | |
<string>pedro</string> | |
</array> |
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
// TEST 5 app.js | |
// this is the app that will be launched | |
// get the args that the app was launched with | |
var args = Ti.App.getArguments(); | |
var win = Ti.UI.createWindow({ | |
backgroundColor: "blue" | |
}); | |
var button = Ti.UI.createButton({ | |
title: 'Get Args', | |
height: 50, | |
width: 250 | |
}); | |
button.addEventListener('click', function(e){ | |
alert(args); | |
}); | |
win.add(button); | |
win.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
// TEST 7 app.js | |
// This app will launch the app named Test 5 | |
var win = Ti.UI.createWindow({ | |
backgroundColor : 'red' | |
}); | |
var testButton = Ti.UI.createButton({ | |
title : "Open Test 5", | |
height : 50, | |
width : 250, | |
}); | |
testButton.addEventListener('click', function(){ | |
Ti.API.info( Ti.Platform.canOpenURL('test5://') ); | |
Ti.Platform.openURL('test5://'); | |
}); | |
win.add(testButton); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment