What redirect URL to use when redirecting ionic for third party webflow

狂风中的少年 提交于 2019-12-19 04:21:22

问题


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?


回答1:


abstract:

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

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

and

$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

code:

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');
    });
  });

helpful links:

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

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




回答2:


It sounds that you will need to handle popup and redirects, you will need to install the cordova "inappbrowser" plugin in order to be able to open the thrid party webflow inside the app browser and then go back to normal.

Please take a look at this article in where they are explaining how to deal with facebook authentification using the firebase login methods with Ionic and cordova. It describes very similar steps that you will need to tackle your problem.

Firebase simple login with Ionic and Cordova

If you are in a rush start from "Getting It Working in the Emulator" but I recommend reading all the article quickly.

I am not sure which kind of third party webflow are you using, but maybe this could help you: Zapier




回答3:


I was looking for the same thing and found this plugin:

https://github.com/EddyVerbruggen/Custom-URL-scheme/blob/d1432ecfff63678a3155804839dda21607706e72/README.md



来源:https://stackoverflow.com/questions/26553639/what-redirect-url-to-use-when-redirecting-ionic-for-third-party-webflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!