Am trying to use integrate oauth in my Hybrid app and am using angularjs 1 with cordova. I tried using this plugin https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller along with https://github.com/EddyVerbruggen/Custom-URL-scheme
But its not straight forward and clear for me. Am facing two issues
- Unable to redirect to app after oauth is done.
- How to close the chrome custom tab and get the data in the app after oauth is done.
Below is what am trying.
Client Side Code:
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);
}
who will call this handleopenurl function ?
In the plugin there is no method for hide() to close the chrome custom tab
ServerSide :
Am using ChromeCustomTabPlugin.java from the plugin mentioned above
Please help am struggling from 2 days. It would be great if some one can provide end-to-end example