簡體   English   中英

Cordova / Phonegap oauth.io彈出窗口未顯示

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

我正在開發Cordova Web應用程序,實際上我集成了oauth.io API,並使用自己的服務器守護程序使其正常運行。

當我嘗試通過桌面瀏覽器上的社交網站登錄時,它的工作原理就像一個超級按鈕,但是當我嘗試在ios模擬器上運行時,它無法正常工作,它無法打開通過社交網站連接的彈出窗口。

所以我安裝了這個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>
.....

我使用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;
          }
        };
      }]
    };
});

但是無論如何它都行不通,您有任何線索嗎?

謝謝

這是我每次在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.

我有同樣的問題。 這個答案在以下網址提示我: https : //stackoverflow.com/a/20576744/327458

在XCode中,我必須手動將CDVInAppBrowser.m添加到Build Phases / Compiled Sources。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM