Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#3169 state:fixed-in-qa] Allow the oldschool in-app authorization fr…

…om Facebook, and in fact, force that to be the default (to match Android).
  • Loading branch information...
commit fd2f4d31c5303c7f5578364ff9339aacc7f95a2c 1 parent 34bcc1f
Stephen Tramer sptramer authored
13 demos/KitchenSink/Resources/examples/facebook_login_logout.js
View
@@ -2,7 +2,6 @@
var win = Ti.UI.currentWindow;
Titanium.Facebook.appid = "134793934930";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
-
//
// Login Status
//
@@ -15,6 +14,18 @@ var label = Ti.UI.createLabel({
});
win.add(label);
+var forceButton = Ti.UI.createButton({
+ title:'Force dialog: '+Titanium.Facebook.forceDialogAuth,
+ top:50,
+ width:160,
+ height:40
+});
+forceButton.addEventListener('click', function() {
+ Titanium.Facebook.forceDialogAuth = !Titanium.Facebook.forceDialogAuth;
+ forceButton.title = "Force dialog: "+Titanium.Facebook.forceDialogAuth;
+});
+win.add(forceButton);
+
function updateLoginStatus() {
label.text = 'Logged In = ' + Titanium.Facebook.loggedIn;
}
1  iphone/Classes/FBConnect/Facebook.h
View
@@ -46,6 +46,7 @@
- (void)authorize:(NSString *)application_id
permissions:(NSArray *)permissions
+ forceDialog:(BOOL)forceDialog
delegate:(id<FBSessionDelegate2>)delegate;
- (BOOL)handleOpenURL:(NSURL *)url;
3  iphone/Classes/FBConnect/Facebook.m
View
@@ -201,6 +201,7 @@ -(NSDictionary*)parseURLParams:(NSString *)query {
*/
- (void)authorize:(NSString*)application_id
permissions:(NSArray*)permissions
+ forceDialog:(BOOL)forceDialog
delegate:(id<FBSessionDelegate2>)delegate {
[_appId release];
@@ -211,7 +212,7 @@ - (void)authorize:(NSString*)application_id
_sessionDelegate = delegate;
- [self authorizeWithFBAppAuth:YES safariAuth:YES];
+ [self authorizeWithFBAppAuth:!forceDialog safariAuth:!forceDialog];
}
/**
1  iphone/Classes/FacebookModule.h
View
@@ -24,6 +24,7 @@
NSString *appid;
NSArray *permissions;
NSMutableArray *stateListeners;
+ BOOL forceDialogAuth;
}
@property(nonatomic,readonly) Facebook *facebook;
28 iphone/Classes/FacebookModule.m
View
@@ -143,6 +143,7 @@ -(void)startup
VerboseLog(@"[DEBUG] facebook startup");
[super startup];
+ forceDialogAuth = YES;
[self _restore];
[self handleRelaunch];
}
@@ -262,6 +263,18 @@ -(id)permissions
* JS example:
*
* var facebook = require('facebook');
+ * alert(facebook.forceDialogAuth);
+ *
+ */
+-(id)forceDialogAuth
+{
+ return [NSNumber numberWithBool:forceDialogAuth];
+}
+
+/**
+ * JS example:
+ *
+ * var facebook = require('facebook');
* alert(facebook.accessToken);
*
*/
@@ -314,6 +327,19 @@ -(void)setPermissions:(id)arg
* JS example:
*
* var facebook = require('facebook');
+ * facebook.forceDialogAuth = true;
+ * alert(facebook.forceDialogAuth);
+ *
+ */
+-(void)setForceDialogAuth:(id)arg
+{
+ forceDialogAuth = [TiUtils boolValue:arg def:NO];
+}
+
+/**
+ * JS example:
+ *
+ * var facebook = require('facebook');
*
* facebook.addEventListener('login',function(e) {
* if (e.success) {
@@ -357,7 +383,7 @@ -(void)authorize:(id)args
[self _unsave];
NSArray *permissions_ = permissions == nil ? [NSArray array] : permissions;
- [facebook authorize:appid permissions:permissions_ delegate:self];
+ [facebook authorize:appid permissions:permissions_ forceDialog:forceDialogAuth delegate:self];
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.