PGB Android URL Scheme not working

  • 1
  • Problem
  • Updated 5 years ago
  • Acknowledged
Keep getting this error

Error - Malformed config.xml - You can fix this here

Not sure what is wrong on the code below

[gap:config-file platform="android" parent="/manifest/application" mode="add" ]
[!-- registers to receive SEND and VIEW intents from other apps --]
[activity android:name="MyURLScheme" android:label="@string/app_name"]
[intent-filter]
[action android:name="android.intent.action.SEND" /]
[category android:name="android.intent.category.DEFAULT" /]
[data android:mimeType="text/*" /]
[/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="MyURLScheme"/]
[/intent-filter]
[/activity]
[/gap:config-file]
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
  • anxious

Posted 5 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
please post your entire config.xml. Please use some HTML when you post your code. (see attached image)
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
[?xml version="1.0" encoding="UTF-8" ?]
[widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.abcxyz.MyURLScheme"
versionCode = "120"
version = "1.2.0" ]

[name]My App[/name]

[description]
AAAAA
[/description]

[author href="http://MyURLScheme.com" email="support@MyURLScheme.com"]
MyURLScheme.Com
[/author]

[preference name="LoadingPageDialog" value="My App"/]

[preference name="phonegap-version" value="cli-5.2.0" /]

[icon src="icon.png" /]

[icon gap:platform="android" gap:qualifier="ldpi" src="res/icon/android/icon-36-ldpi.png" /]
[icon gap:platform="android" gap:qualifier="mdpi" src="res/icon/android/icon-48-mdpi.png" /]
[icon gap:platform="android" gap:qualifier="hdpi" src="res/icon/android/icon-72-hdpi.png" /]
[icon gap:platform="android" gap:qualifier="xhdpi" src="res/icon/android/icon-96-xhdpi.png" /]
[icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" /]
[icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" /]
[icon gap:platform="ios" height="120" src="res/icon/ios/icon-120.png" width="120" /]
[icon gap:platform="ios" height="76" src="res/icon/ios/icon-76.png" width="76" /]
[icon gap:platform="ios" height="152" src="res/icon/ios/icon-152.png" width="152" /]
[icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" /]
[icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" /]
[icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" /]
[icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" /]
[icon gap:platform="webos" src="res/icon/webos/icon-64.png" /]
[icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" /]
[icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173-tile.png" /]
[gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" /]
[gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" /]
[gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" /]
[gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" /]
[gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" /]
[gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" /]
[gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" /]
[gap:splash gap:platform="ios" height="1136" src="res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" /]
[gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" /]
[gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" /]
[gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" /]

[preference name="AutoHideSplashScreen" value="true" /]
[preference name="SplashScreenDelay" value="0" /]

[preference name="orientation" value="landscape" /]
[preference name="webviewbounce" value="false"/]
[preference name="prerendered-icon" value="true" /]
[preference name="ios-statusbarstyle" value="black-translucent" /]
[preference name="fullscreen" value="true" /]
[preference name="stay-in-webview" value="false" /]

[gap:plugin name="org.apache.cordova.dialogs" source="npm" /]
[gap:plugin name="org.apache.cordova.vibration" source="npm" /]
[gap:plugin name="org.apache.cordova.device" source="npm" /]
[gap:plugin name="org.apache.cordova.splashscreen" source="npm" /]
[gap:plugin name="org.apache.cordova.network-information" source="npm" /]
[gap:plugin name="org.apache.cordova.file-transfer" source="npm" /]
[gap:plugin name="org.apache.cordova.camera" source="npm" /]
[gap:plugin name="org.apache.cordova.file" source="npm" /]
[gap:plugin name="org.apache.cordova.media-capture" source="npm" /]
[gap:plugin name="org.apache.cordova.console" source="npm" /]
[gap:plugin name="cordova-plugin-whitelist" source="npm" /]

[gap:plugin name="org.apache.cordova.camera" source="npm" /]
[gap:plugin name="org.apache.cordova.inappbrowser" source="npm" /]

[access origin="*" /]

[allow-navigation href="http://*/*" /]

[gap:url-scheme name="com.abcxyz.MyURLScheme" role="None"]
[scheme]MyURLScheme[/scheme]
[/gap:url-scheme]

[gap:config-file platform="android" parent="/manifest/application" mode="add" ]
[activity android:name="MyURLScheme" android:label="@string/app_name"]
[intent-filter]
[action android:name="android.intent.action.SEND" /]
[category android:name="android.intent.category.DEFAULT" /]
[data android:mimeType="text/*" /]
[/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="MyURLScheme"/]
[/intent-filter]
[/activity]
[/gap:config-file]

[/widget]
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.abcxyz.MyURLScheme"
versionCode = "120"
version = "1.2.0" >

<name>My App</name>

<description>
AAAAA
</description>

<author href="http://MyURLScheme.com" email="support@MyURLScheme.com">
MyURLScheme.Com
</author>

<preference name="LoadingPageDialog" value="My App"/>

<preference name="phonegap-version" value="cli-5.2.0" />

<icon src="icon.png" />

<icon gap:platform="android" gap:qualifier="ldpi" src="res/icon/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="res/icon/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="res/icon/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />
<icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="ios" height="120" src="res/icon/ios/icon-120.png" width="120" />
<icon gap:platform="ios" height="76" src="res/icon/ios/icon-76.png" width="76" />
<icon gap:platform="ios" height="152" src="res/icon/ios/icon-152.png" width="152" />
<icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
<icon gap:platform="webos" src="res/icon/webos/icon-64.png" />
<icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" />
<icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173-tile.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" />
<gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1136" src="res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
<gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" />

<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="0" />

<preference name="orientation" value="landscape" />
<preference name="webviewbounce" value="false"/>
<preference name="prerendered-icon" value="true" />
<preference name="ios-statusbarstyle" value="black-translucent" />
<preference name="fullscreen" value="true" />
<preference name="stay-in-webview" value="false" />

<gap:plugin name="org.apache.cordova.dialogs" source="npm" />
<gap:plugin name="org.apache.cordova.vibration" source="npm" />
<gap:plugin name="org.apache.cordova.device" source="npm" />
<gap:plugin name="org.apache.cordova.splashscreen" source="npm" />
<gap:plugin name="org.apache.cordova.network-information" source="npm" />
<gap:plugin name="org.apache.cordova.file-transfer" source="npm" />
<gap:plugin name="org.apache.cordova.camera" source="npm" />
<gap:plugin name="org.apache.cordova.file" source="npm" />
<gap:plugin name="org.apache.cordova.media-capture" source="npm" />
<gap:plugin name="org.apache.cordova.console" source="npm" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" />

<gap:plugin name="org.apache.cordova.camera" source="npm" />
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm" />

<access origin="*" />

<allow-navigation href="http://*/*" />

<gap:url-scheme name="com.abcxyz.MyURLScheme" role="None">
<scheme>MyURLScheme</scheme>
</gap:url-scheme>

<gap:config-file platform="android" parent="/manifest/application" mode="add" >
<activity android:name="MyURLScheme" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</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="MyURLScheme"/>
</intent-filter>
</activity>
</gap:config-file>

</widget>
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
ugh, looks like crap, but if you can read it, I am all for it
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. The XML Validator complains that the :android namespace is missing. It can't process the attributes that start with "android:"

2. You should also check if you have any leading or trailing whitespace (spaces, tabs, returns) within this file before <?xml or after </widget>. Such whitespace makes the XML not-well-formed.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Might be an issue with adding Android activities with config.xml - we'll run some tests to confirm the issue.

Just to confirm, does using cordova-plugin-customurlscheme from npm work? https://github.com/EddyVerbruggen/Custom-URL-scheme

-yiming
(Edited)
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
yes

And where do you see the android namespace on the code above?
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
Any news on this Yi?
This is still not working
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
You have the android namespace inside your gap:config-file element:
<activity android:name="MyURLScheme" ...

In order to use the android namespace in your config.xml, you need to declare it first, like so:

<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android = "http://schemas.android.com/apk/res/android"
id = "com.omg.wtf"
version = "2.0.1">
...
Photo of ullfindsmit

ullfindsmit

  • 20 Posts
  • 0 Reply Likes
Thanks Ryan
That did the trick

However, I instantly have the next problem
My app crashes on android
The same code works on iPhone

I removed everything and simply made it call that function
Still no luck

What am I doing wrong here?


function handleOpenURL(url) {
try{
alert("called handleOpenURL with " + url)
return;
}catch(e){
alert(e);
}
}