I am working with titanium platform, when i implement SSO in iOS, it works great whether i do it for one time or many times, it works smoothly and perfect. but when i come to Android, it work for the first time but not after that.
For example, i installed the test app on android and click on facebook login, it works for first time, but when i logged out and try to login with facebook again then it just shows the redirection to facebook app but app login doesn't happen, i tried many times and try many ways but its not working.
I have placed facebook login event listener in app.js and in somewindow.js i have facebook login button. i am doing some work after logging in facebook, means redirecting to some other window.
thanks in advance.
Actually the problem persist due to cache . we need to clear cache when you log out use below code it works fine
Titanium.Facebook.appid = "XXXXXXXXXXXXXXXXXX";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
var fbButton = Ti.UI.createButton({
top: 68,
width:290,
height:52,
backgroundImage:"images/login/facebook.png"
});
fbButton.addEventListener('click', function() {
if(Titanium.Facebook.loggedIn){
Titanium.Facebook.logout()
return
}
Titanium.Facebook.authorize();
});
Ti.Facebook.addEventListener('login', function(e) {
if (e.success) {
win.close()
} else if (e.error) {
alert(e.error);
} else if (e.cancelled) {
alert("Canceled");
}
});
Titanium.Facebook.addEventListener('logout', function(e) {
var url = 'https://login.facebook.com';
var client = Titanium.Network.createHTTPClient();
client.clearCookies(url);
});
Use this flag Ti.Facebook.forceDialogAuth=false;
Related
Im using ngOpenFB on Ionic, and Ive got my callback set to localhost:8100/oauthcallback.html
$scope.submit= function () {
ngFB.login({scope: 'email'}).then(
function (response) {
if (response.status === 'connected') {
alert('Facebook login succeeded');
} else {
alert('Facebook login failed');
}
});
}
When I hit submit, the oauthcallback.html window gets opened, and in the url I see the valid access token. However, neither of the alerts fire. Theres is no success, and no failure. Just a blank oauthcallback.html page, with the access token in the URL.
I know I can use some trickery to just get that token from the URL and close the window myself. But surely this should be automatic in the ngOpenFB library?
Like it should do it for me no?? Store in sessionStorage, and close the window.
Otherwise, if I don't solve this, Im just going to do it the hacky way, and get the token, and save it myself.
But any ideas on why its not working as it should?
I am trying to implement Facebook app invite with this plugin in my ionic application. The implemented codes are following as below:
$scope.appInviteToFriend = function(user){
var url = "";
if (ionic.Platform.isAndroid())
{
url = "https://play.google.com/store/apps/details?id=com.example.application";
}
else if (ionic.Platform.isIOS())
{
url = "https://itunes.apple.com/nl/app/example-by-ionicapplication/id1983838444?l=en&mt=8";
}
var option = {
url: url,
picture : ""
};
facebookConnectPlugin.appInvite(
option,
function(obj){
if(obj) {
if(obj.completionGesture == "cancel") {
// user canceled, bad guy
} else {
// user really invited someone :)
}
} else {
// user just pressed done, bad guy
}
},
function(obj){
// error
console.log(obj);
}
);
}
When I executed these codes, the Facebook Invite Dialog opens and displayed app information correctly. But after click next button, select friend and also click send button, The error occurs. It says "Missing App Link URL. The app link used with this invite does not contain an Android or iOS URL.Developers are required to enter URl for at least one platform.". I've attached the error details with part of screenshot. Are these wrong the URLs which are store URL? How can I set the URLs?
You need to provide an App Link instead of a web URL. This link can be statically generated using Facebook's own tools, or you can generate them dynamically server-side. You can read more about these in the documentation.
Here's a tutorial that walks through setting up an Android app.
I am using Facebook plugin (http://ngcordova.com/docs/plugins/facebook/
) of Cordova. I am using this plugin with ionic framework. I am all done with installing this plugin on android. I have created an appId and the app is under development. So for the testing I am using test user generated in - https://developers.facebook.com/apps/123456789/roles/test-users/ I want to share a feed on Facebook but I am not able to do that. I am checking getLoginStatus method and on its success I want to post a feed. Here is my code
$scope.getFbLoginStatus = function(){
$cordovaFacebook.getLoginStatus()
.then(function(success) {
alert("Logged In");
$scope.shareFeed = function(){
$cordovaFacebook.showDialog({method: "feed", link:"https://github.com/Wizcorp/phonegap-facebook-plugin/commit/7b4a56f5717a50d3387abe4a2fa6156fe1aea852", caption: "Here is the caption"
})
.then(function(success) {
alert("check whether image shared or not" );
// success
}, function (error) {
alert("image not shared");
// error
});
}
}, function (error) {
alert("Permission denied");
});
}
I have not used facebook SDK as it was not listed in the installation steps.
I want to implement Facebook feed dialog using ionic framework. Please help me and suggest where I am going wrong.
There was problem in the Facebook app-id. It is working fine now. Make sure you generate the correct key hash for the settings of Facebook app_id.
I'm using Phonegap Build.
First of all, I need to say that this error doesn't happen if I try it with an administrator account of the app.
It only happen if a normal user tries to login in my app.
This is my code so far.
var facebookPermissions = ['public_profile', 'email', 'user_about_me', 'user_website'];
$(document).on('click', '#btnFacebook', function() { //click
facebookConnectPlugin.login(facebookPermissions, onFacebookLoginSuccess, onFacebookLoginError)
});
function onFacebookLoginSuccess(userData) {
alert("userData: " + JSON.stringify(userData));
facebookConnectPlugin.api('me', facebookPermissions,
function(result) {
alert("Result: " + JSON.stringify(result));
});
};
I'm the app's administrator and every work as expected... no trouble at all.
But if another user tries to login, the login works well, but there is no response for the api request.
Only the first alert is displayed
I also tried with this parameters
facebookConnectPlugin.api("/?fields=id,email",facebookPermissions,
facebookConnectPlugin.api("",facebookPermissions,
But nothing changes
I'm kinda lost here, and I dont know what else to try.
Your App may be in sandbox mode, activate it in the "Settings & Review" section
user_website needs to get reviewed. Without Login Review, it will only work for users with a role in the App.
I have recently decided to test Cordava FacebookConnect (https://github.com/mgcrea/cordova-facebook-connect).
I have managed to install on an Android project which works on the Android Virtual Device. But when I plugin my Samsung GS3, The device has a fit and just keeps refreshing the application.
My code is very basic:
var app = {
initialize : function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
var facebookConnect = window.plugins.facebookConnect;
console.log('ready');
facebookConnect.login(
{
permissions : ["email", "user_about_me"],
appId : "3560694656564117"
}, function(result)
{
console.log("FacebookConnect.login:" + JSON.stringify(result));
if( result.cancelled || result.error ) {
console.log("FacebookConnect.login:failedWithError:" );
}
});
}
};
What is weird is that the console logs "ready" every second which is not inside the facebookConnect callback. It as if I have previously logged in, revisited the app, the plugin verifies my credentials, the dialog closes and then it starts again! If I comment out the facebookConnect login method it just loads as normal, the console logs "ready" only the once.
Has anyone come across this before?
Regards
Make sure you setup the native android app section in the facebook app dashboard. Especially the hash key section.
You should indicate whether the facebook callback got called or not.
You can always look in the logcat if there are fb errors that come out.