简体   繁体   English

Cordova / Phonegap oauth.io弹出窗口未显示

[英]Cordova / Phonegap oauth.io popup not showing

im developing a cordova webapp, actually i integrated the oauth.io API and i use a own server daemon to make it work. 我正在开发Cordova Web应用程序,实际上我集成了oauth.io API,并使用自己的服务器守护程序使其正常运行。

When i try to login via socials on desktop browser it works like a charm, but when i try on ios simulator it wont work, it doesnt open the popup to connect via socials. 当我尝试通过桌面浏览器上的社交网站登录时,它的工作原理就像一个超级按钮,但是当我尝试在ios模拟器上运行时,它无法正常工作,它无法打开通过社交网站连接的弹出窗口。

So i installed this https://github.com/oauth-io/oauth-phonegap changed config.xml file to allow all origins in this way: 所以我安装了这个https://github.com/oauth-io/oauth-phonegap更改的config.xml文件,以这种方式允许所有来源:

    .....
     <content src="index.html" />
    <access origin="*" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />

    <!-- Don't store local date in an iCloud backup. Turn this to "cloud" to enable storage
         to be sent to iCloud. Note: enabling this could result in Apple rejecting your app.
    -->
    <preference name="BackupWebStorage" value="none" />
    <feature name="StatusBar">
      <param name="ios-package" value="CDVStatusBar" onload="true" />
    </feature>
    <feature name="InAppBrowser">
       <param name="ios-package" value="CDVInAppBrowser" />
    </feature>
.....

I use ionicframework so my oauth code is javascript/angularjs as i can show here: 我使用ionicframework,所以我的oauth代码是javascript / angularjs,因为我可以在这里显示:

 .provider('OAuthd', function () {

    var theClientId = '';

    return {

      'setClientId': function(value) {
        theClientId = value;
      },
      '$get': ['$window', '$q', '$cacheFactory', function ($window, $q, $cacheFactory) {

        var cache = $cacheFactory('OAuthdProviderCache');
        ($window.OAuth.initialize || angular.noop)(theClientId);

        return {
          'facebook' : function() {

            var facebookAPI = cache.get('facebook')
              , deferred = $q.defer();

            if (!facebookAPI) {

              $window.OAuth.popup('facebook', function(err, result) {

                if (!err) {

                  deferred.resolve(result);
                } else {

                  deferred.reject(err);
                }
              });
              cache.put('facebook', deferred.promise);
              return deferred.promise;
            }

            return facebookAPI;
          },
          'twitter': function() {

            var twitterAPI = cache.get('twitter')
              , deferred = $q.defer();

            if (!twitterAPI) {

              $window.OAuth.popup('twitter', function(err, result) {

                if (!err) {

                  deferred.resolve(result);
                } else {

                  deferred.reject(err);
                }
              });
              cache.put('twitter', deferred.promise);
              return deferred.promise;
            }

            return twitterAPI;
          },
          'google': function() {

            var googlePlusAPI = cache.get('google_plus')
              , deferred = $q.defer();

            if (!googlePlusAPI) {

              $window.OAuth.popup('google_plus', function(err, result) {

                if (!err) {

                  deferred.resolve(result);
                } else {

                  deferred.reject(err);
                }
              });

              cache.put('google_plus', deferred.promise);
              return deferred.promise;
            }

            return googlePlusAPI;
          }
        };
      }]
    };
});

But it wont work anyway, do you have any clue? 但是无论如何它都行不通,您有任何线索吗?

thanks 谢谢

this is what the cordova console.log returns everytime i try it on ios simulator or android simulator: 这是我每次在ios模拟器或android模拟器上尝试它时cordova console.log返回的内容:

Terminating in response to SpringBoard's termination.
2014-08-08 11:18:53.958 chatting[4573:70b] Multi-tasking -> Device: YES, App: YES
2014-08-08 11:18:53.971 chatting[4573:70b] Unlimited access to network resources
2014-08-08 11:18:54.000 chatting[4573:70b] CDVPlugin class IonicKeyboard (pluginName: keyboard) does not exist.
2014-08-08 11:18:54.000 chatting[4573:70b] [CDVTimer][keyboard] 0.589967ms
2014-08-08 11:18:54.001 chatting[4573:70b] CDVPlugin class CDVStatusBar (pluginName: statusbar) does not exist.
2014-08-08 11:18:54.002 chatting[4573:70b] [CDVTimer][statusbar] 0.699997ms
2014-08-08 11:18:54.002 chatting[4573:70b] [CDVTimer][TotalPluginStartup] 2.420008ms
2014-08-08 11:18:54.351 chatting[4573:70b] Resetting plugins due to page load.
2014-08-08 11:18:55.026 chatting[4573:70b] Finished load of: file:///Users/macuser/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CA5E4763-35DA-44A3-A907-77E58E4CB181/chatting.app/www/index.html#/app/home
2014-08-08 11:18:55.274 chatting[4573:70b] CDVPlugin class IonicKeyboard (pluginName: Keyboard) does not exist.
2014-08-08 11:18:55.275 chatting[4573:70b] ERROR: Plugin 'Keyboard' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 11:18:55.275 chatting[4573:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "INVALID",
  "Keyboard",
  "hideKeyboardAccessoryBar",
  [
    true
  ]
]
2014-08-08 11:19:06.985 chatting[4573:70b] CDVPlugin class CDVInAppBrowser (pluginName: InAppBrowser) does not exist.
2014-08-08 11:19:06.985 chatting[4573:70b] ERROR: Plugin 'InAppBrowser' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 11:19:06.986 chatting[4573:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "InAppBrowser1514682083",
  "InAppBrowser",
  "open",
  [
    "http:\/\/auth.mysite.eu\/auth\/facebook?k=Jnpo3LK9wWrScy_cZ5xOQ5Fctx4&d=file%3A%2F%2F%2F&opts=%7B%22state%22%3A%222A9nV3-_ZBGs8HbZKVn_ffmy5MA%22%2C%22state_type%22%3A%22client%22%7D",
    "Authorization",
    "width=800,height=350,toolbar=0,scrollbars=1,status=1,resizable=1,location=1,menuBar=0,left=-240,top=16.25"
  ]
]
2014-08-08 11:19:06.987 chatting[4573:70b] CDVPlugin class CDVLogger (pluginName: Console) does not exist.
2014-08-08 11:19:06.988 chatting[4573:70b] ERROR: Plugin 'Console' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 11:19:06.988 chatting[4573:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "INVALID",
  "Console",
  "logLevel",
  [
    "ERROR",
    "Error: 'undefined' is not a function (evaluating 'wnd.focus()')\npopup@http:\/\/auth.mysite.eu\/download\/latest\/oauth.js:323:15\nfacebook@file:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/assets\/js\/providers.js:27:34\nsignup@file:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/assets\/js\/controllers.js:91:24\nfile:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/lib\/ionic\/js\/ionic.bundle.js:19654:26\nfile:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/lib\/ionic\/js\/ionic.bundle.js:42758:21\n$eval@file:\/\/\/Users\/macuser\/Library\/Application%20Support[...]
2014-08-08 18:12:18.174 chatting[7825:70b] Multi-tasking -> Device: YES, App: YES
2014-08-08 18:12:31.794 chatting[7825:70b] Unlimited access to network resources
2014-08-08 18:12:49.439 chatting[7825:70b] CDVPlugin class IonicKeyboard (pluginName: keyboard) does not exist.
2014-08-08 18:12:49.440 chatting[7825:70b] [CDVTimer][keyboard] 0.704050ms
2014-08-08 18:12:49.440 chatting[7825:70b] CDVPlugin class CDVStatusBar (pluginName: statusbar) does not exist.
2014-08-08 18:12:49.441 chatting[7825:70b] [CDVTimer][statusbar] 0.515997ms
2014-08-08 18:12:49.441 chatting[7825:70b] [CDVTimer][TotalPluginStartup] 2.322972ms
2014-08-08 18:12:54.431 chatting[7825:70b] Resetting plugins due to page load.
2014-08-08 18:13:06.581 chatting[7825:70b] Finished load of: file:///Users/macuser/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CA5E4763-35DA-44A3-A907-77E58E4CB181/chatting.app/www/index.html#/app/home
2014-08-08 18:13:08.127 chatting[7825:70b] CDVPlugin class IonicKeyboard (pluginName: Keyboard) does not exist.
2014-08-08 18:13:08.127 chatting[7825:70b] ERROR: Plugin 'Keyboard' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 18:13:08.127 chatting[7825:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "INVALID",
  "Keyboard",
  "hideKeyboardAccessoryBar",
  [
    true
  ]
]
2014-08-08 18:14:37.227 chatting[7825:70b] CDVPlugin class CDVInAppBrowser (pluginName: InAppBrowser) does not exist.
2014-08-08 18:14:37.228 chatting[7825:70b] ERROR: Plugin 'InAppBrowser' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 18:14:37.228 chatting[7825:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "InAppBrowser1564421013",
  "InAppBrowser",
  "open",
  [
    "http:\/\/auth.mysite.eu\/auth\/facebook?k=Jnpo3LK9wWrScy_cZ5xOQ5Fctx4&d=file%3A%2F%2F%2F&opts=%7B%22state%22%3A%226EG62ptFFZVSaIg2e2QCZXYx5Ak%22%2C%22state_type%22%3A%22client%22%7D",
    "Authorization",
    "width=800,height=350,toolbar=0,scrollbars=1,status=1,resizable=1,location=1,menuBar=0,left=-240,top=16.25"
  ]
]
2014-08-08 18:14:37.229 chatting[7825:70b] CDVPlugin class CDVLogger (pluginName: Console) does not exist.
2014-08-08 18:14:37.229 chatting[7825:70b] ERROR: Plugin 'Console' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-08-08 18:14:37.229 chatting[7825:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
  "INVALID",
  "Console",
  "logLevel",
  [
    "ERROR",
    "Error: 'undefined' is not a function (evaluating 'wnd.focus()')\npopup@http:\/\/auth.mysite.eu\/download\/latest\/oauth.js:323:15\nfacebook@file:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/assets\/js\/providers.js:27:34\nsignup@file:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/assets\/js\/controllers.js:91:24\nfile:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/lib\/ionic\/js\/ionic.bundle.js:19654:26\nfile:\/\/\/Users\/macuser\/Library\/Application%20Support\/iPhone%20Simulator\/7.1\/Applications\/CA5E4763-35DA-44A3-A907-77E58E4CB181\/chatting.app\/www\/lib\/ionic\/js\/ionic.bundle.js:42758:21\n$eval@file:\/\/\/Users\/macuser\/Library\/Application%20Support[...]
Terminating in response to SpringBoard's termination.

I had this same problem. 我有同样的问题。 This answer clued me in: https://stackoverflow.com/a/20576744/327458 . 这个答案在以下网址提示我: https : //stackoverflow.com/a/20576744/327458

In XCode, I had to manually add CDVInAppBrowser.m to Build Phases / Compiled Sources. 在XCode中,我必须手动将CDVInAppBrowser.m添加到Build Phases / Compiled Sources。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM