重定向离子第三方的Webflow时要使用什么重定向网址 [英] What redirect URL to use when redirecting ionic for third party webflow

查看:417
本文介绍了重定向离子第三方的Webflow时要使用什么重定向网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个离子的移动应用程序中,我想重定向到一个第三方的Webflow它要求用户的同意,并重定向到回调URL我应该具体为我抢该令牌许可令牌做进一步的API调用。由于离子本身是一个HTML5的移动应用程序,我该指定什么重定向URL,以便控制又回到我的手机应用程序?

I am developing a ionic mobile app in which i want to redirect to a thirdparty webflow which requests users' consent and redirects to the callback url which i should specific for me to grab the token as permission token to make further API calls. Since ionic itself is a html5 mobile app, what do i specify for the redirect url so the control comes back to my mobile app?

推荐答案

这不正是你所要求的东西,但它的工作原理pretty很好。

abstract:

This isn't exactly what you are asking for, but it works pretty well.

的想法是,你使用的 $ cordovaInAppBrowser 的打开网页视图和侦听事件,即
$ cordovaInAppBrowser:loadstart

The Idea is that you use $cordovaInAppBrowser to open a webview and listen for events, namely $cordovaInAppBrowser:loadstart

$ cordovaInAppBrowser:loaderror

然后你可以看一下传递错误和事件参数,并利用这些来确定,如果你想打电话

you can then look at the error and event arguments that are passed and use those to determine if you want to call

$ cordovaInAppBrowser.close();

这将返回到你的应用程序离子

which will return you to your ionic app

angular.module('myApp', ['ionic', 'ngCordova']).controller('AppCtrl', function($rootScope, $ionicPlatform, $cordovaInAppBrowser) {
    $scope.openThirdPartyWhatever = function() {
      $ionicPlatform.ready(function() {
        var options = {
          location: 'yes',
          clearcache: 'no',
          toolbar: 'yes'
        };
        $cordovaInAppBrowser.open('http://www.myAwesomeSite.com', '_blank', options)
      });
    };

    //at some point your app tries to load 'http://localhost:8100/send-me-back-to-app'
    $rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event) {
      //and this function is called, so you do something like
      if(event.url === 'http://localhost:8100/send-me-back-to-app'){
        $cordovaInAppBrowser.close();
      }
    });

    $rootScope.$on('$cordovaInAppBrowser:loaderror', function(e, event) {
      $cordovaInAppBrowser.close();
      alert('sorry, something went wrong');
    });
  });

有用的链接:

https://www.genuitec.com/products/gapdebug/

http://ngcordova.com/docs/plugins/inAppBrowser/

这篇关于重定向离子第三方的Webflow时要使用什么重定向网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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