EddyVerbruggen / Custom-URL-scheme

:link: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://
1.03k stars 367 forks source link

Unable to open app from inappbrowser and from php #240

Open Sea-Eagle opened 7 years ago

Sea-Eagle commented 7 years ago

I have followed instructions as mentioned here and (http://mcgivery.com/using-custom-url-schemes-ionic-framework-app/)

but when I try to open app from in app browser plugin window.open = cordova.InAppBrowser.open; var inAppBrowserRef = cordova.InAppBrowser.open('ionicapp://', '_blank', 'location=yes'); It is giving error that "ERR_UNKNOWN_URL_SCHEME"

even I tried from browser still not opening (open the browser and in the address bar i have pasted "ionicapp://")

AdamAtri commented 6 years ago

I am also getting an "ERR_UNKNOWN_URL_SCHEME" error from the InAppBrowser. This only occurs in Android. iOS works as expected.

cordova cli version: 7.1.0 customUrlScheme plugin version: ^4.3.0 inAppBrowser plugin version: ^1.7.1

from config.xml ...

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="myapp:*" />

... <engine name="android" spec="^6.3.0" />

<plugin name="cordova-plugin-crosswalk-webview" spec="~2.3.0">
        <variable name="XWALK_VERSION" value="23+" />
        <variable name="XWALK_LITEVERSION" value="xwalk_core_library_canary:17+" />
        <variable name="XWALK_COMMANDLINE" value="--disable-pull-to-refresh-effect" />
        <variable name="XWALK_MODE" value="embedded" />
        <variable name="XWALK_MULTIPLEAPK" value="true" />
</plugin>
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-camera" spec="^2.4.1">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="MyApp would like to use your camera." />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="MyApp  would like to access your photo library." />
</plugin>
<plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
<plugin name="cordova-plugin-console" spec="~1.0.7" />
<plugin name="cordova-plugin-camera-preview" spec="^0.9.0" />
<plugin name="cordova-plugin-dialogs" spec="^1.3.3" />
<plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
        <variable name="URL_SCHEME" value="myapp" />
</plugin>
<plugin name="cordova-plugin-compat" spec="^1.2.0" />
<plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />

from AndroidManifest

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
       <intent-filter android:label="@string/launcher_name">
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
       </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="myapp" />
       </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:host=" " android:pathPrefix="/" android:scheme=" " />
       </intent-filter>
</activity>
davidanquetin commented 6 years ago

Hello,

exactly the same problem

if window is opened with system browser (chrome for example), the app is well launched with url_scheme myapp:// but if window is opened with cordova inappbrowser, app is not re-opened, and i have an error in the webview : "ERR_UNKNOWN_URL_SCHEME"

Has someone fixed this problem ? @EddyVerbruggen , any idea ?

thanks !

ankitch01 commented 6 years ago

Add your app uri scheme under InAppBrowserClient in your cordova “InAppBrowser.java” file.

@Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url) {

 if( url.startsWith("yourapp:") {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(url));
                    cordova.getActivity().startActivity(intent);
                    return true;
                }
ibrahimcanbaz commented 3 years ago

Perfect! Worked ! just added one parenthesis for if. Thanks, @ankitch01

if( url.startsWith("yourapp:") ){
                   Intent intent = new Intent(Intent.ACTION_VIEW);
                   intent.setData(Uri.parse(url));
                   cordova.getActivity().startActivity(intent);
                   return true;
               }
mosabab commented 3 years ago

Perfect! Worked ! just added one parenthesis for if. Thanks, @ankitch01

if( url.startsWith("yourapp:") ){
                   Intent intent = new Intent(Intent.ACTION_VIEW);
                   intent.setData(Uri.parse(url));
                   cordova.getActivity().startActivity(intent);
                   return true;
               }

Could you please put the line of inappbrowser.java that need to modify? Thanks

sagargopale1992 commented 2 years ago

Add your app uri scheme under InAppBrowserClient in your cordova “InAppBrowser.java” file.

@Override
       public boolean shouldOverrideUrlLoading(WebView webView, String url) {

if( url.startsWith("yourapp:") {
                   Intent intent = new Intent(Intent.ACTION_VIEW);
                   intent.setData(Uri.parse(url));
                   cordova.getActivity().startActivity(intent);
                   return true;
               }

awesome ,it worked !!