为第三方 webflow 重定向 ionic 时要使用的重定向 URL [英] What redirect URL to use when redirecting ionic for third party webflow

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

问题描述

我正在开发一个 ionic 移动应用程序,我想在其中重定向到第三方 webflow,该 webflow 请求用户同意并重定向到回调 url,我应该专门为我获取令牌作为权限令牌以进行进一步的 API 调用.由于 ionic 本身是一个 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?

推荐答案

摘要:

这不是您所要求的,但效果很好.

abstract:

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

这个想法是你使用 $cordovaInAppBrowser 打开一个 webview 并监听事件,即$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();

这将使您返回到您的 ionic 应用

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 重定向 ionic 时要使用的重定向 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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