@@ -127,10 +127,11 @@ public class InAppBrowser extends CordovaPlugin {
127
127
private static final String FOOTER_COLOR = "footercolor" ;
128
128
private static final String BEFORELOAD = "beforeload" ;
129
129
private static final String FULLSCREEN = "fullscreen" ;
130
+ private static final String ALLOWEDSCHEMES = "allowedschemes" ;
130
131
private static final int MY_PERMISSIONS_REQUEST_RECORD_AUDIO = 101 ;
131
132
private static final int MY_PERMISSIONS_REQUEST_CAMERA = 102 ;
132
133
133
- private static final List customizableOptions = Arrays .asList (CLOSE_BUTTON_CAPTION , TOOLBAR_COLOR , NAVIGATION_COLOR , CLOSE_BUTTON_COLOR , FOOTER_COLOR );
134
+ private static final List customizableOptions = Arrays .asList (CLOSE_BUTTON_CAPTION , TOOLBAR_COLOR , NAVIGATION_COLOR , CLOSE_BUTTON_COLOR , FOOTER_COLOR , ALLOWEDSCHEMES );
134
135
135
136
private InAppBrowserDialog dialog ;
136
137
private WebView inAppWebView ;
@@ -181,6 +182,11 @@ public boolean execute(String action, CordovaArgs args, final CallbackContext ca
181
182
}
182
183
final String target = t ;
183
184
final HashMap <String , String > features = parseFeature (args .optString (2 ));
185
+ final String customscheme = features .get (ALLOWEDSCHEMES );
186
+ if (customscheme != null ) {
187
+ LOG .d (LOG_TAG , "customscheme = " + customscheme );
188
+ allowedSchemes = customscheme .split ("/" );
189
+ }
184
190
185
191
LOG .d (LOG_TAG , "target = " + target );
186
192
@@ -1444,15 +1450,26 @@ else if (url.startsWith(INTENT_PROTOCOL_START)) {
1444
1450
}
1445
1451
// Test for whitelisted custom scheme names like mycoolapp:// or twitteroauthresponse:// (Twitter Oauth Response)
1446
1452
else if (!url .startsWith ("http:" ) && !url .startsWith ("https:" ) && url .matches ("^[A-Za-z0-9+.-]*://.*?$" )) {
1447
- try {
1448
- JSONObject obj = new JSONObject ();
1449
- obj .put ("type" , "customscheme" );
1450
- obj .put ("url" , url );
1451
- sendUpdate (obj , true );
1452
- override = true ;
1453
- } catch (JSONException ex ) {
1454
- LOG .e (LOG_TAG , "Custom Scheme URI passed in has caused a JSON error." );
1453
+ if (allowedSchemes != null ) {
1454
+ for (String scheme : allowedSchemes ) {
1455
+ if (scheme .equals ("all" ) || url .startsWith (scheme )) {
1456
+ LOG .d (LOG_TAG , "execute deeplink [" + url + "]" );
1457
+ try {
1458
+ cordova .getActivity ().startActivity (new Intent (Intent .ACTION_VIEW , Uri .parse (url )));
1459
+ } catch (ActivityNotFoundException e ) {
1460
+ LOG .e (LOG_TAG , "not installed deeplink app [" + url + "] : " + e .toString ());
1461
+ }
1462
+ override = true ;
1463
+ break ;
1464
+ }
1465
+ }
1466
+ if (!override ) {
1467
+ LOG .e (LOG_TAG , "not allowed this scheme [" + url + "]" );
1468
+ }
1469
+ } else {
1470
+ LOG .e (LOG_TAG , "no allowedSchemes" );
1455
1471
}
1472
+ return true ;
1456
1473
}
1457
1474
if (useBeforeload ) {
1458
1475
this .waitForBeforeload = true ;
0 commit comments