科尔多瓦在应用程序浏览器事件未触发IOS [英] Cordova In App Browser event not firing IOS

查看:95
本文介绍了科尔多瓦在应用程序浏览器事件未触发IOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过外部服务在我的离子应用程序上对用户进行身份验证,我需要在应用程序浏览器中使用cordovas!该代码可在android上完美运行,但是在iOS上,"loadstop"事件不会触发,因此,浏览器也不会将自身重定向回应用程序.我的代码如下所示:

Trying to authenticate users on my ionic application through an external service and I need to use cordovas In app browser! The code works perfectly on android however on iOS the "loadstop" event never fires and thus, the browser never redirects itself back to the application. The code I have looks like this:

$rootScope.$on('$cordovaInAppBrowser:loadstop', function (e, event) {
        console.log('inappbrowser loaded', event);

        var regex = /* regex to determine if url is correct redirected url */
        var res = regex.test(event.url);
        alert('loaded: ' + event.url);
        alert('regex result: ' + res);
        if(res === true) {
          $cordovaInAppBrowser.close();
        }
      });

      if(okta) {
        if (typeof window.localStorage.msRefreshToken === 'undefined') {
          document.addEventListener('deviceready', function () {
            $cordovaInAppBrowser.open('urlforExternalservicehere', '_blank', options);
          }, false);
        } else {
          TokenStore.refreshAccessToken();
        }
      }

运行代码时,屏幕上没有警报.同样,一旦应用程序到达了外部服务并输入了用户名,便会将其重定向到另一个URL,然后该用户将使用另一组凭据进行身份验证.反过来,这会返回一个令牌,供应用程序进行身份验证.

when the code is run no alert appears on the screen. Also, once the app has reached the external service and the username of the user is entered, it is then redirected to another url, which the user will then use another set of credentials to authenticate against. This in turn returns a token for the application to authenticate use.

因此,在一个完美的iOS世界中,它与当前的Android体验相匹配,loadstop事件将触发3次,第三次将触发"loadstop"事件,而regex将返回true并关闭应用程序内浏览器.

Thus, in a perfect iOS world where it matches the current android experience, the loadstop event fires three times, and the third time the "loadstop" event would fire and the regex would return true and close the in app broswer.

如果我需要提供更多代码来帮助解决此问题,请告诉我!

If I need to supply more code to help solve this issue please let me know!

科尔多瓦版本:4.2.0
离子性:1.4.5
iOS:8和9
将NgCordova用于Cordova功能

Cordova Version: 4.2.0
Ionic: 1.4.5
iOS: 8 and 9
Using NgCordova for Cordova functionality

更新:在模拟器上运行应用程序并检查控制台日志时,我发现此错误:

UPDATE: when running the application on an emulator and checking the console logs, I find this error:

错误:模块cordova-plugin-inappbrowser.inappbrowser没有 存在., http://10.117.1.46:8100/cordova.js ,行:1402

Error: Module cordova-plugin-inappbrowser.inappbrowser does not exist., http://10.117.1.46:8100/cordova.js, Line: 1402

我已经安装了插件,所以我不知道它怎么缺少插件.有人对此有补救办法吗?谢谢!

I have the plugin installed so I don't know how its missing the plugin. Does anyone have a remedy for this? Thanks!

推荐答案

问题不是我的iOS平台最新.

Problem was my iOS platform wasn't latest.

因此,当您使用cordova开发应用程序时,请确保您的平台版本和插件是最新的,并且已升级操作系统.

So when you developing apps using cordova make sure your platform versions and plugins are up-to date with OS upgraded.

所以我要做的就是

删除iOS平台.

cordova平台rm ios

cordova platform rm ios

添加iOS平台-最新版本

Adding iOS platform - Latest Version

cordova平台添加ios

cordova platform add ios

删除插件cordova-plugin-inappbrowser

Removing the plugin cordova-plugin-inappbrowser

cordova插件删除cordova-plugin-inappbrowser

cordova plugin remove cordova-plugin-inappbrowser

添加插件cordova-plugin-inappbrowser-最新版本

Adding the plugin cordova-plugin-inappbrowser - Latest Version

cordova插件添加cordova-plugin-inappbrowser

cordova plugin add cordova-plugin-inappbrowser

这篇关于科尔多瓦在应用程序浏览器事件未触发IOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆