我正在编写一些在AppBrowser中打开的代码,客户端可以在我的网站上完成某些操作,然后从我的应用程序中收听事件并在完成后关闭浏览器。但是在调用open之后,下面的所有其他代码行都不会被调用。
var options = {
location: 'yes',
clearcache: 'no',
toolbar: 'no'
},
url=appConfig.appUrl + '/premium/'+$scope.videoData.slug+'/payment';
$ionicLoading.show();
$cordovaInAppBrowser.open(url, '_blank', options).catch(function() {
$scope.showAlert('Error', 'There was an error reaching the server');
});
//below here never executes
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
alert('mr');
var loc = event.url;
console.log(e, event);
//when url is changed check if the url contains your specific callbackURL
if (loc.indexOf('successfuls') >= 0) {
//at this point close your inapp browser
//you will land on the index page within your application.
$cordovaInAppBrowser.close();
$ionicLoading.hide();
$scope.showAlert('Successfull!', 'You successfully purc+hased download for this video!');
$scope.is_expired = false;
$scope.is_video = true;
$scope.time_diff = +$scope.videoData.premium_duration * 3600;
}
if(loc.indexOf('failed') >=0){
$cordovaInAppBrowser.close();
$ionicLoading.hide();
$scope.showAlert('Alert', 'Could not process payment!')
}
});`
任何人都知道为什么会发生这种情况,检查浏览器和设备上的行为会产生相同的结果。