Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-3912 in a recent build.
  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    3
    Vote Rating
    0
    smaccona is on a distinguished road

      0  

    Default ST 2.1 and 2.2alpha: Ext.device.Device.scheme is false on launch from custom URL

    ST 2.1 and 2.2alpha: Ext.device.Device.scheme is false on launch from custom URL


    Summary: successfully created a native iOS app 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.

    Details:

    Following the instructions at http://docs.sencha.com/touch/2-1/#!/....device.Device to specify a Custom Scheme URL for my native iOS app.

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

    Steps to reproduce:
    1. Generate a new app using
      Code:
      $ sencha generate app -path /Library/WebServer/Documents/SchemeTest
    2. Add 'Ext.device.Device' to the requires: property of the application
    3. Add the following code to the launch function in app.js:
      Code:
      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);
    4. Specify a custom URL scheme by adding the following line to packager.json:
      Code:
          "rawConfig": "<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>sencha</string></array><key>CFBundleURLName</key><string>com.sencha.example</string></dict></array>"
      This will cause URLs of the form sencha:HereIsMyURL to open your app on an iOS device or the iOS Simulator.
    5. Run the app in iOS Simulator with this command:
      Code:
      $ sencha package run packager.json
    6. 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:
      Scheme1.png
    7. 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:
      Scheme2.png
    8. The app will reopen and you will see the URL has been correctly passed in:
      Scheme3.png
    9. 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:
      Scheme4.png
    10. 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.
    11. The app will start, but Ext.device.Device.scheme is still false and so the URL cannot be retrieved.
      Scheme1.png
    12. (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.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    3
    Vote Rating
    0
    smaccona is on a distinguished road

      0  

    Default


    This has been listed as fixed in the header of this post for two months, but I have no idea how we can obtain this fix. Can you provide some guidance here?

    Thanks!

  4. #4
    Sencha User
    Join Date
    Mar 2013
    Posts
    5
    Vote Rating
    0
    thhuebner is on a distinguished road

      0  

    Default Not working in ST 2.1.1

    Not working in ST 2.1.1


    I'm observing here the same problem. Ext.device.Device.scheme is always false. The application needs to run to obtain the url from another app.

    Is this fixed in later versions?

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Vote Rating
    0
    mobilab is on a distinguished road

      0  

    Default


    Got it working here (even when removed from memory).
    I used my applicationId as the name for the string inside CFBundleURLName and inside the new sencha touch command I ran: sencha app build native (in the folder where the packager.json file resides).

  6. #6
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    4
    tgolembiewski is on a distinguished road

      0  

    Default


    Quote Originally Posted by mobilab View Post
    Got it working here (even when removed from memory).
    I used my applicationId as the name for the string inside CFBundleURLName and inside the new sencha touch command I ran: sencha app build native (in the folder where the packager.json file resides).
    On which version you've managed it to work? 2.2.0 or 2.1.1??

  7. #7
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Vote Rating
    0
    mobilab is on a distinguished road

      0  

    Default


    Hi,

    I am running Sencha 2.1.1, but I got the latest cmd tool.

    --André

  8. #8
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Vote Rating
    0
    mobilab is on a distinguished road

      0  

    Default


    Sorry to mention that I didn't read the first item correctly. Opening the app by usage of url scheme is what I got working, but I am not getting any url the first time either.

  9. #9
    Sencha Premium Member
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    4
    tgolembiewski is on a distinguished road

      0  

    Default


    use device.scheme instead of Ext.device this will not work in browser (until you mocket it up ) but will work on ipad.

  10. #10
    Sencha User
    Join Date
    Feb 2013
    Posts
    47
    Vote Rating
    0
    mobilab is on a distinguished road

      0  

    Default


    Hi,

    I added all possible combinations inside the launch method :-), but none of them works. I guess I need 2.2?

    if (device.scheme)
    console.log('device.scheme: ' + device.scheme);
    if (Ext.device.scheme)
    console.log('Ext.device.scheme: ' + Ext.device.scheme);
    if (Ext.device.device.scheme)
    console.log('Ext.device.device.scheme: ' + Ext.device.device.scheme);