Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23182] Facebook login is not working on iOS

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2016-04-10T18:53:56.000+0000
Affected Version/sRelease 5.2.2
Fix Version/sn/a
ComponentsiOS
Labelsfacebook, ios, login
ReporterMostafizur Rahman
AssigneeChee Kiat Ng
Created2016-04-08T19:03:01.000+0000
Updated2016-04-10T18:53:56.000+0000

Description

Facebook login is not working on latest SDK. *Testing Environment:* Titanium SDK: 5.2.2.GA Appcelerator Command-Line Interface, version 5.2.2 Facebook module version: 5.0.1 Testing device: iPod 5G(9.2) *Testing Code:*
var fb = require('facebook');
var win = Ti.UI.createWindow({
	title : 'Login/Logout',
	backgroundColor : '#fff',

});
var label = Ti.UI.createLabel({
	text : 'Logged In = ' + fb.loggedIn,
	color : '#000',
	font : {
		fontSize : 20
	},
	top : 10,
	textAlign : 'center'
});
win.add(label);
fb.addEventListener('login', function(e) {
	if (e.success) {
		alert('login from uid: ' + e.uid + ', name: ' + JSON.parse(e.data).name);
		label.text = 'Logged In = ' + fb.loggedIn;
	} else if (e.cancelled) {
		// user cancelled
		alert('cancelled');
	} else {
		alert(e.error);
	}
});
fb.authorize();
fb.addEventListener('logout', function(e) {
	alert('logged out');
	label.text = 'Logged In = ' + fb.loggedIn;
});
var loginButton = fb.createLoginButton({
	readPermissions : ['email'],
	top : 100,
	width : 150,
	height : 100
});

win.add(loginButton);
win.open();
*Testing Result:* Facebook login not working and login dialog not appear for IOS.

Comments

  1. Sharif AbuDarda 2016-04-08

    Hello, I have tested the issue in iOS simulator and device with SDK 5.2.1.GA, 5.2.2.GA. I couldn't reproduce the issue. Facebook Login is working as expected. Use the below code instead. Facebook module Version 5.1.0
       var fb = require('facebook');
       
       var win = Ti.UI.createWindow({
       
           title : 'Login/Logout',
       
           backgroundColor : '#fff',
       
       });
       
       var label = Ti.UI.createLabel({
       
           text : 'Logged In = ' + fb.loggedIn,
       
           color : '#000',
       
           font : {
       
               fontSize : 20
       
           },
       
           top : 10,
       
           textAlign : 'center'
       
       });
       
       win.add(label);
       
       fb.addEventListener('login', function(e) {
       
           if (e.success) {
       
               alert('login from uid: ' + e.uid + ', name: ' + JSON.parse(e.data).name);
       
               label.text = 'Logged In = ' + fb.loggedIn;
       
           } else if (e.cancelled) {
       
               // user cancelled
       
               alert('cancelled');
       
           } else {
       
               alert(e.error);
       
           }
       
       });
       
       fb.initialize();
       fb.authorize();
       fb.addEventListener('logout', function(e) {
       
           alert('logged out');
       
           label.text = 'Logged In = ' + fb.loggedIn;
       
       });
       
       var loginButton = fb.createLoginButton({
       
           readPermissions : ['email'],
       
           top : 100,
       
           width : 150,
       
           height : 100
       
       });
       
       win.add(loginButton);
       
       win.open();
       
    I have added this additional code. This is required after you set up login/logout listeners and permissions
       fb.initialize();
       
    Regards, Sharif.

JSON Source