此插件的Cordova Facebook登录问题https://github.com/jeduan/cordova-pl



我的代码出了什么问题?我已经安装了cordova插头面板4我还提供了我从developers.facebook.com.获得的适当的APP_ID和APP_NAME

我是PhoneGap项目的新手。

错误:

1.  Uncaught DOMException: Blocked a frame with origin "https://staticxx.facebook.com" from accessing a cross-origin frame.
at <anonymous>:1:16
2. (index):32 Uncaught ReferenceError: facebooConnectPlugin is not defined
at LoginWithFB ((index):32)
at HTMLButtonElement.onclick ((index):23)

代码:

<!DOCTYPE html>
<html>
<head>

<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Hello World</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
<button type="button" onclick="LoginWithFB()" class="btn btn-primary" style="background-color: blue;padding:5%;" >Login With Facebook</button>
</div>
</div>
<script type="text/javascript">
function LoginWithFB()
{
alert('Function Start Here');
facebooConnectPlugin.login(['public_profile','email'],function(result){ 
alert('You Completed 1st Stage');
alert(JSON.stringify(result));
alert('Now Going To The Next Step');
//Success Login Function 
facebooConnectPlugin.api("me?fields=email,name,picture",['public_profile','email'],function(userData){
alert('Sorry You Completed Last Round Too..Now You Could Be Logged IN');
alert(JSON.stringify(userData));
},function(error){
alert('Hurrey You Got Erorr 2');
alert(JSON.stringify(error));
});
//Last Error Function 
},function(error){
alert('Hurrey You Got A Error');
alert(JSON.stringify(error));
});
alert('Function End  Here');
}
</script>
</body>
</html>

cordova-plugin-facebook4不工作

使用phonegap的facebook插件-https://www.npmjs.com/package/phonegap-facebook-plugin

使用代码安装

cordova plugin add phonegap-facebook-plugin

希望它能有所帮助!

相关内容

最新更新