Android Facebook插件在爱奥尼亚1中不起作用
我正在开发一个应用程序从离子-1。我还实现了facebook登录插件。我跟着。我没有错误,但当我点击facebook按钮时,它不工作,没有显示错误。我在每个错误捕获中使用Android Facebook插件在爱奥尼亚1中不起作用,android,angularjs,ionic-framework,ionic-native,phonegap-facebook-plugin,Android,Angularjs,Ionic Framework,Ionic Native,Phonegap Facebook Plugin,我正在开发一个应用程序从离子-1。我还实现了facebook登录插件。我跟着。我没有错误,但当我点击facebook按钮时,它不工作,没有显示错误。我在每个错误捕获中使用警报,但不会显示警报 注意:我在一个真正的android设备上运行,因为他们说本机插件在浏览器中不起作用 请帮助我,因为我正在写论文。谢谢大家 这是我的密码: .controller('CreateAccountCtrl', ['$scope','$http','$state','$q','UserService','$stat
警报
,但不会显示警报
注意:我在一个真正的android设备上运行,因为他们说本机插件在浏览器中不起作用
请帮助我,因为我正在写论文。谢谢大家
这是我的密码:
.controller('CreateAccountCtrl', ['$scope','$http','$state','$q','UserService','$stateParams', '$ionicLoading','$timeout','$ionicPopup',function($scope, $http,$state,$q, UserService,$stateParams,$ionicLoading,$timeout,$ionicPopup){
$scope.$on('$ionicView.beforeEnter', function(e){
$ionicLoading.show({
animation: 'fade-in', showBackdrop: true
});
});
$scope.$on('$ionicView.afterEnter', function(e){
$ionicLoading.hide();
$scope.formData = {};
$scope.showAlert = function(ttl,msg){
var alertPopup = $ionicPopup.alert({
title: ttl,
template: msg
});
};
});
// facebook
// This is the success callbak from the login method
var fbLoginSuccess = function(response){
if(!response.authResponse){
fbLoginError("Cannot find the authResponse");
return;
}
var authResponse = response.authResponse;
getFacebookProfileInfo(authResponse)
.then(function(profileInfo){
// store user data on local storage
UserService.setUser({
authResponse: authResponse,
userID: profileInfo.id,
name: profileInfo.name,
email: profileInfo.email,
picture: "http://graph.facebook.com/" + authResponse.userID + "/picture?type=large"
});
$ionicLoading.hide();
$state.go('app.home');
}, function(fail){
alert(fail);
// Fail get profile info
console.log('Profile Info Fail', fail);
});
};
// This is the fail callback from the login method
var fbLoginError = function(error){
console.log('fbLoginError', error);
alert(error);
$ionicLoading.hide();
};
// This method is to get the user profile info from the facebook api
var getFacebookProfileInfo = function(authResponse){
var info = $q.defer();
facebookConnectPlugin.api('/me?fields=email,name&access_token=' + authResponse.accessToken, null,
function(response){
alert(response);
console.log(response);
info.resolve(response);
},
function(response){
console.log(response);
alert(response);
info.reject(response);
}
);
return info.promise;
};
// This method is executed when the user press the "Login with faceboook" button
$scope.facebookSignIn = function(){
alert(1);
facebookConnectPlugin.getLoginStatus(function(success){
if(success.status === 'connected'){
// The user is logged in and has authenticated your app, and response.authResponse supplies
// the user's ID, a valid access token, a signed request, and the time the access token
// and signed request each expire
console.log('getLoginStatus', success.status);
alert(success.status);
// Check if we have our user saved
var user = UserService.getUser('facebook');
if(!user.userID){
getFacebookProfileInfo(success.authResponse)
.then(function(profileInfo){
UserService.setUser({
authResponse: success.authResponse,
userID: profileInfo.id,
name: profileInfo.name,
email: profileInfo.email,
picture : "http://graph.facebook.com/" + success.authResponse.userID + "/picture?type=large"
});
$state.go('app.home');
}, function(fail){
console.log('Profile info fail', fail);
alert(fail);
});
}else{
$state.go('app.home');
}
}else{
// If (success.status === 'not_authorized') the user is logged in to Facebook,
// but has not authenticated your app
// Else the person is not logged into Facebook,
// so we're not sure if they are logged into this app or not.
console.log('getLoginStatus', success.status);
alert(success.status);
$ionicLoading.show({
template: 'Logging in...'
});
facebookConnectPlugin.login(['email','public_profile'], fbLoginSuccess, fbLoginError);
}
});
};
}]);
在我的html中
<a class="facebook-sign-in button button-block button-facebook" ng-click="facebookSignIn()">
<i class="icon ion-social-facebook"></i>
Sign in using facebook
</a>
使用facebook登录
APP\u NAME=“必须是在facebook开发者上创建的facebook应用程序名,而不是你的应用程序名”
APP_ID=facebook应用程序ID
使用facebook v4安装
$cordova plugin add cordova-plugin-facebook 4--保存--变量APP_ID=“123456789”--变量APP_NAME=“myApplication”
你是说它在$scope.facebookSignIn()内从不触发警报(1)?@billy_漫画它触发警报(1)先生。当我点击按钮,这就是它。它只是提醒:(请帮我确定。也许有几件事。我不知道你在控制器顶部的控制器中注入了Facebook插件(注入$ionicPopup等)。你是否包含了src=“”到你索引中的插件了吗?没有。我没有包括源代码。我想它会被自动调用。我会在那里放一个断点,然后检查插件引用,以确保它不会在未定义的情况下返回。
$rootScope.loginFacebook = function() {
$cordovaFacebook.login(["public_profile", "email", "user_birthday", "user_photos"]).then(function(success){
console.info(success.status);
if (success.status === 'connected') {
var checkrequest = {
'AuthSession[device_token]': $localStorage.device_token
}
appname.check(checkrequest).then(function(response) {
console.log(response);
if (response.key == "NOAUTH") {
$state.go('main.allowPush')
}
})
} else if (success.status === 'not_authorized') {
console.info('the user is logged in to Facebook but has not
authenticated your app')
} else {
console.info('the user is nott logged in to Facebook')
}
}, function(error) {
console.info(error);
});
}