chrome 自定义选项卡未重定向回混合应用

chrome custom tabs not redirecting back to hybrid app

我正在尝试在我的混合应用程序中使用集成 oauth,并且正在使用 angularjs 1 和 cordova。我尝试使用这个插件 https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller 以及 https://github.com/EddyVerbruggen/Custom-URL-scheme

但这对我来说并不直接明了。 我面临两个问题

  1. oauth 完成后无法重定向到应用程序。
  2. 如何在 oauth 完成后关闭 chrome 自定义选项卡并获取应用程序中的数据。

以下是我正在尝试的内容。

客户端代码:

var options=[{url:oauthPostURL,hidden:false,animated:false}];
$scope.openUrl = function(options) {
            console.log("inside openurl--");
            var deferred  = $q.defer();
            try{
                cordova.exec( 
            // success function
            function(response){
                       deferred.resolve(response);
                    },
              //failure function
                    function(response){
                        deferred.resolve(false);
                    },
              "ChromeCustomTabPlugin", "show", options);

            }catch(e){
                console.log("error in corodva plugin ::"+e);
            }
            return deferred.promise;
        }

 function handleOpenURL(url) {
  setTimeout(function() {
    //SafariViewController.hide();
    var data = decodeURIComponent(url.substr(url.indexOf('=')+1));
    console.log('Browser data received: ' + data);
  }, 0);
}

谁来调用这个 handleopenurl 函数?

插件中没有 hide() 关闭 chrome 自定义选项卡的方法

ServerSide :

我正在使用上述插件中的 ChromeCustomTabPlugin.java

请帮助我挣扎了 2 天。如果有人能提供端到端的例子就好了

我自己解决了。 有几个错误。 我手动添加了自定义-url-schema 插件。

  • HandleopenUrl函数放在全局的页面中,我放在 index.html 中的函数是我的起始页。

  • LaunchMyApp.java 自定义-url-插件中的文件丢失

  • launchMyApp.js 文件丢失。

    <plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
        <variable name="URL_SCHEME" value="" />
        <variable name="ANDROID_SCHEME" value="" />
        <variable name="ANDROID_HOST" value="" />
        <variable name="ANDROID_PATHPREFIX" value="/" />
     </plugin>

  • config.xml 中的这一行缺失。