Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8127] iOS: You can't call the Facebook Authorization from a Dialog (not even with app events)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-17T14:58:33.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-08
ComponentsiOS
LabelsSupportTeam, api
ReporterMauro Parra-Miranda
AssigneeBlain Hamon
Created2012-03-20T15:31:37.000+0000
Updated2017-03-06T18:16:45.000+0000

Description

Problem Description

Customer adds a Facebook.authorize(); from an app, without any results.

Actual Results

The function never goes and logs into facebook.

Expected results

The app should be able to login into fb

Test Case

1. Create a new mobile project 2. Add the code in the example to a button 3. Run it
wishToShareViaFacebook.addEventListener('click', function(e){ 
 if (e.index == 0) { 
   if (Titanium.Facebook.loggedIn) { 
   var data = { link: "www.jokwear.com", name: "Great Apparel, Great Message", message: "Check out JokWear!", caption: "Follow your favourite athletes, support other athletes", picture: "http://jokwear.com/images/joklogo.gif", description: "JokWear is a clothing brand that not only touts excellent fabric but also a social movement that you can achieve anything you set your mind to.", test: [ {foo:'Encoding test', bar:'Durp durp'}, 'test' ] }; Titanium.Facebook.requestWithGraphPath('me/feed', data, 'POST', showRequestResult); 
} else {
    Titanium.Facebook.authorize();
}
}
});

Extra info

There is a bug where platform didn't want to launch the FB authorize from a dialog, since it's bad practice to get a dialog from a dialog. So, we recommended the customer to add an app event catching this, closing the dialog and then adding the other dialog. It's not runnning. The customer creates a small function doing a setTimeout, and that way, the function it's called properly within the if.

Comments

  1. Neeraj Gupta 2012-03-20

    Mauro - Please provide the complete environment information for these tickets.
  2. Mauro Parra-Miranda 2012-04-12

    Done. Best, Mauro
  3. Blain Hamon 2012-04-16

    Aha. I think I get at what's happening here. I might be able to modify Kitchen Sink to recreate the situation. Basically, since the dialog is a real UI window and becomes the key window, the FB module tries to insert itself into the dialog as it goes away.
  4. Blain Hamon 2012-04-16

    Mauro, does this describe what you're seeing?
       // Set Titanium.Facebook.appid
       // Set Titanium.Facebook.permissions
       
       var authenticateButton = Ti.UI.createButton({
       	title:'Authenticate',
       	top:110,
       	width:160,
       	height:40
       });
       authenticateButton.addEventListener('click', function() {
       	var a = Titanium.UI.createAlertDialog({
       		title:'Authorize?',
       		buttonNames:['Authorize','Cancel'],
       		cancel:2,
       	});
       	a.addEventListener('click', function(e)
       	{
       		if(e.index==0){
       			var temp = Titanium.Facebook.forceDialogAuth;
       			Titanium.Facebook.forceDialogAuth=true;			
       			Titanium.Facebook.authorize();
       			Titanium.Facebook.forceDialogAuth = temp;
       		}
       	});
       	a.show();
       });
       win.add(authenticateButton);
       
  5. Blain Hamon 2012-04-16

    Pull https://github.com/appcelerator/titanium_mobile/pull/2018 pending.
  6. Mauro Parra-Miranda 2012-04-17

    Yes, that's the behavior! TY! M
  7. Lee Morris 2017-03-06

    Closing ticket due to time passed.

JSON Source