Summary: successfully created a native iOS app in Sencha Touch 2.1 (and 2.2alpha) with a custom URL scheme. In both iOS Simulator and on a real device, launching the app from cold using the custom URL does not pass the URL to the app (Ext.device.Device.scheme is always false, regardless of whether you start the app using the custom URL or not). If the app is already running in the background, however, then the custom URL used to resume it is successfully passed to the schemeupdate event. The launching-from-cold behavior is not consistent with the documentation, and I need a workaround to get the custom URL when the app is started from cold.

This occurs on both Sencha Touch 2.1 and 2.2alpha and on both iOS 5 and iOS 6.

Steps to reproduce:

Generate a new app using:

$ sencha generate app -path /Library/WebServer/Documents/SchemeTest

Add 'Ext.device.Device' to the requires: property of the application as per the documentation linked above.

Add the following code to the launch function in app.js:

alert("Scheme is " + Ext.device.Device.scheme);
if (Ext.device.Device.scheme) {
// the application was opened via another application. Do something:
alert('Applicaton pened via another application: ' + Ext.device.Device.scheme.url);
}
// Listen for future changes
Ext.device.Device.on('schemeupdate', function(device, scheme) {
// the application was launched, closed, and then launched another from another application
// this means onReady wont be called again ('cause the application is already running in the
// background) - but this event will be fired
alert('Applicated reopened via another application: ' + scheme.url);
}, this);

Specify a custom URL scheme by adding the following line to packager.json:

This will cause URLs of the form sencha:HereIsMyURL to open your app on an iOS device or the iOS Simulator.

Run the app in iOS Simulator with this command:

$ sencha package run packager.json

The app will start in the iOS Simulator and will show the URL scheme to be false, since the app has not been started using a custom URL:

Click OK to close the alert dialog, then press the Home button on the iOS Simulator to move the app to the background. Open Mobile Safari and enter the URL sencha:HereIsMyURL and press Enter or click the Go button to resume the app:

The app will reopen and you will see the URL has been correctly passed in:

Tap the Home button on iOS Simulator, then double-tap the Home button and hold the mouse button down on the "My Application" icon until the icons start to shake. Use the red "-" to completely kill "My Application" so that it's no longer running:

Press the Home button again, then go back into Mobile Safari and re-enter the URL sencha:HereIsMyURL and press Enter or click the Go button to start the app.

The app will start, but Ext.device.Device.scheme is still false and so the URL cannot be retrieved.

(Optional) Configure your packager.json file with a valid applicationName, applicationId, bundleSeedId, certificateAlias and provisionProfile, and set the platform to iOS. Then rebuild your native app for your real iOS device using $ sencha package build packager.json, copy the app to your device using XCode, and repeat steps 7 through 11 on the real device. The results are the same.

This means that it is only possible to retrieve a custom URL when the app is already running in the background. When starting the app from cold using a custom URL, the app does not correctly detect that a custom URL scheme has been used and so it is not possible to pass information to the app. Does anyone know of a workaround for this?

Having the same problem ! Any solutions yet ?
–
SashaZdMar 25 '13 at 19:02

@SashaZd The bug report I filed at sencha.com/forum/… lists this as fixed, but I don't see it yet in the latest beta. We don't appear to have visibility into the Sencha release schedule so at this point I have no idea when we will see that fix on our end.
–
user533676Mar 26 '13 at 20:22