![](/img/trans.png)
[英]Phonegap canvas not drawing on android but works fine in browser
[英]Facebook login works fine in browser but doesn't work on android with phonegap
在嘗試實現每個版本的phonegap facebook插件大約2天后,我決定放棄它,並在我的應用程序中實現純JS登錄系統。 老實說,本機登錄系統不值得處理此插件...
我遵循了Facebook開發者網站上的說明,並且我的登錄在桌面瀏覽器上可以完美運行。 我用phonegap編譯並嘗試在android設備上運行后,問題開始了。 當我按下登錄按鈕時,出現“未在...處定義FB”的信息,這是由於嘗試訪問FB.login()方法導致的。
相關代碼是:
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXXX', // contains my App ID
channelUrl : 'YYYYYYYYYYYY', // contains my Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
// Here we specify what we do with the response anytime this event occurs.
if (response.status === 'connected') {
testAPI();
active_access_token = response.authResponse.accessToken;
$.mobile.changePage("#main_page");
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
// Load the SDK asynchronously
(function(d){
console.log ("async load started!");
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
按鈕接線:
function set_buttons() {
$("#facebook_login_button").click(function(){
console.log("login attempt");
FB.login();
});
同樣,這在瀏覽器中完美運行。 在phonegap編譯后,我無法使其在android上工作。
想法?
好吧,我想通了...
由於我是從locahost運行它的,因此我在其中添加了“ http:”
js.src = "//connect.facebook.net/en_US/all.js";
所以現在是:
js.src = "http://connect.facebook.net/en_US/all.js";
嘗試轉到您的Facebook應用>設置>高級,然后在“有效的OAuth重定向URI”上添加正確的網址
對我來說,這與在iOS部分的開發者Facebook應用設置上添加BundleID有關。 這可能會幫助我的船上的其他人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.