Search code examples
rubyrhomobilerhodes

Rhomobile: Custom URL Schemes


I'm writing a Rhomobile application targeted at iPhone and Android.
I need to create a custom url scheme, so that i can create urls that look like test://some-params that will launch my program and will pass it the params.

As far as I understand this is done in build.yml through the BundleURLScheme parameter, and then System.get_start_params() to get those parameters. However, this works on the iPhone only as far as I understand. Is there any way to make this work on Android too?

Thanks alot!


Solution

  • OKay, I've found the answer myself, in case anybody needs this too:

    • Create an extension to the application as explained here: http://docs.rhomobile.com/rhodes/extensions#generating-a-native-extension-template
    • Add an android_manifest_changes file, as decribed in the above link.
    • In that file add the following lines:

      <manifest xmlns:android='http://schemas.android.com/apk/res/android'
      android:versionName='1.0' package='com.rhomobile.webbrowserpoc'
      android:versionCode='10000' android:installLocation='auto'>
      <application android:name='com.rhomobile.rhodes.RhodesApplication'
          android:label='@string/app_name' android:icon='@drawable/icon'
          android:debuggable='true'>
          <activity android:name='com.rhomobile.rhodes.RhodesActivity'
              android:label='@string/app_name' android:launchMode='singleTask'
              android:configChanges='orientation|keyboardHidden'
              android:screenOrientation='unspecified'>
              <intent-filter>
                  <action android:name='android.intent.action.VIEW' />
                  <category android:name='android.intent.category.BROWSABLE' />
                  <category android:name='android.intent.category.DEFAULT' />
                  <data android:pathPrefix='' android:scheme=''
                      android:host='' />
              </intent-filter>
          </activity>
      </application>
      

    Only the <data android:pathPrefix='' android:scheme='' android:host='' /> line should be filled in with correct properties.