ngCordovaOauth Twitter不在离子1应用程序中工作

时间:2018-02-09 09:40:12

标签: ionic-framework oauth cordova-plugins twitter-oauth twitter-login

我已经为社交登录安装了ngCordovaOauth插件。 Facebook和Instagram工作正常,但当我尝试使用Twitter登录时它无法正常工作。还安装了白名单和inappbrowser插件

的index.html

<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js"></script>
<script src="js/sha/sha1.js"></script>

模板文件代码

<div class="loginPgRow socialLogins">
<img src="img/facebook.png" class="loginImg" ng-click="LoginwithFacebook()"/>
<img src="img/twitter.png" class="loginImg" ng-click="LoginwithTwitter()"/>
<img src="img/instagram.png" class="loginImg" ng-click="LoginwithInstagram()"/>
</div>

Controller.js

angular.module('starter.controllers', ['ionic', 'ngCordova', 'ngCordovaOauth', 'app.factories.localstorage', 'ionic.cloud'])
.controller('AppCtrl', function($scope, $ionicModal, $timeout, $ionicPopup, $ionicPlatform, $state, $stateParams, $translate,$window, $ionicPush, $ionicAuth, $ionicUser, $ionicLoading, $ionicPopover, $cordovaDevice, $cordovaOauth, $http){
    $scope.LoginwithTwitter = function() 
    {
      var consumerKey = "Consumer Key (API Key)"; 
      var consumerSecretKey = "Consumer Secret (API Secret)";
      $cordovaOauth.twitter(consumerKey,consumerSecretKey).then(function(result){
        alert('success');
      },  function(error){
        alert('error');
      });
    };
});

0 个答案:

没有答案