FBSDKLoginButton with native iOS dialog - ios

I have my login button setup like this.
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
loginButton.loginBehavior = 0; // native
[self.view addSubview:loginButton];
What I wish to have is a native login dialog instead of the web view one, so I assign the loginBehavior to 0, as specified in this enum
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) {
FBSDKLoginBehaviorNative = 0,
FBSDKLoginBehaviorBrowser,
FBSDKLoginBehaviorSystemAccount,
FBSDKLoginBehaviorWeb,
};
However, no matter what behavior I set, I only get web view login.
I am running my app in a real iOS device, with Facebook app installed and authenticated.
I notice apps such as Tinder, or Instagram have their own native login dialogs. Is this a misconfiguration from my part?

Related

FBSDKLikeControl opening facebook instead coming back to app

Trying to add facebook native like button to my app. its only opening my page then after tapping ok or unlike its opening facebook homepage instead of coming back to the applciation
FBSDKLikeControl *likeButton = [[FBSDKLikeControl alloc] init];
[likeButton addTarget:self action:#selector(likeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
likeButton.objectID = #"https://www.facebook.com/a2zTwoWheels/";
likeButton.center = self.view.center;
[fbPopupView addSubview:likeButton];
Please don't suggest existing questions with callback solutions , tried all before posting this question

Facebook login is redirecting to logout page

I have set up a Facebook login for my app and it works but what I don't know how to do is when you log in the app through Facebook, the app should take you to a menu screen that I have created in a view controller. Right now with Facebook login it is taking me to the log out page. Any help would be appreciated.
In my ViewController:-
- (void)viewDidLoad{
[super viewDidLoad];
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.readPermissions = # [#"public_profile", #"email", #"user_friends"];
[self.view addSubview:loginButton];
if ([FBSDKAccessToken currentAccessToken]) {
[self performSegueWithIdentifier:#"Cell" sender:self];
}
}
I am checking if the user is logged in, and if yes perform the segue nothing happens.
When your facebook request complete the authentication process, the FB button is automatically turned into "log-out" mode since that is the next option for the user. To transition to a new view controller you can call a segue in the delegate method as shown below. This method will be called at the end of the FB credentialing, if you have subscribed to the delegate FBSDKLoginButtonDelegate:
- (void)loginButton:(FBSDKLoginButton*)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult*)result
[self performSegueWithIdentifier:#"yourSegueIdentifier" sender:self];
}

Facebook API permissions in iOS

I'm working on an app that uses the Facebook SDK. Until now I've not had any significant problems. I've been using the API to request a user's photos. However, after deleting the app on the device to try out some log-in scenarios, the app now only requests the public profile.
This is the call being made
self.loginView = [[FBLoginView alloc] initWithReadPermissions:#[#"public_profile", #"email", #"user_friends", #"user_photos"]];
but this is what shows on the device
When I request the user's photos the data is empty (as you'd expect with just the public profile).
What did I do to break it? And more importantly, how do I fix it?
EDIT: I've created a new app on the Facebook developer portal and I get exactly the same results.
For reasons I can't establish, this error was somehow connected to the way that the FBLogin was initialising.
In my app I had created an FBLoginView in the storyboard and I was doing the alloc/init in the viewDidLoad method of the view controller handling my Facebook information.
I had checked to ensure that the FBLoginView class was associated with the view in the storyboard and that the FBLoginView class was declared in my app delegate.
However, I was seeing the problem as stated. It was only when I removed the FBLoginView from the storyboard and created it programmatically (as in the FBLoginUIControlSample that's available on Facebook) that the problem was resolved.
For reference, this DID NOT work for me
-(void)viewDidLoad{
[super viewDidLoad];
self.loginView = [[FBLoginView alloc] initWithReadPermissions:#[#"public_profile", #"email", #"user_friends", #"user_photos"]];
self.loginView.delegate = self;
}
This DID work.
-(void)viewDidLoad{
[super viewDidLoad];
FBLoginView *loginView = [[FBLoginView alloc] initWithReadPermissions:#[#"public_profile", #"email", #"user_friends", #"user_photos"]];
loginView.delegate = self;
loginView.frame = CGRectOffset(loginView.frame,
(self.view.center.x - (loginView.frame.size.width / 2)),
5);
loginView.center = self.view.center;
[self.View addSubview:loginView];
}

Implement sign in via twitter in ios

I want to provide functionality to get user sign in via twitter in my app.
I have spend 2 days in just reading the blogs , dev.twitter.com .. but i reached nowhere.
Can anyone help me .. or just tell me any open source app. thats provides this functionality..
thanks
If you develop for IOS 5 and later versions just add Twitter.framework to your target.
User uses settings screen to login and logout to twitter
#import <Twitter/Twitter.h> in your class/viewcontroller.
then call following method anywhere in your code
if ([TWTweetComposeViewController canSendTweet])
{
//yes user is logged in
}
else{
//show tweeet login prompt to user to login
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
}
Also look at this tutorials:
http://www.raywenderlich.com/21558/beginning-twitter-tutorial-updated-for-ios-6
http://mobileorchard.com/ios-tutorial-twitter-integration-in-ios5/
The Social Framework (iOS6) has built-in twitter functionality that will save you some time. In iOS5 there is a (very) similar Twitter Framework.
You need to use OAuth. Read "Getting started with OAuth 2.0" by Ryan Boyd

Sharing photos on facebook from iOS application without facebook app

Is it possible on iOS < 6?
In iOS 6+, I can share using message composer.
What about previous version of iOS? FB SDK share uses facebook app id so it's not the way.
Maybe i can open native facebook app with scheme like fb://share/photo/[image_data]?
Any other ideas?
For iOS < 6, you can always used ShareKit plugin.
In this repository, they share nice example to share image on your fb account.
Have a look at the class ExampleShareImage:
- (void)loadView
{
[super loadView];
self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"sanFran.jpg"]] autorelease];
imageView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height);
[self.view addSubview:imageView];
}
- (void)share
{
SHKItem *item = [SHKItem image:imageView.image title:#"San Francisco"];
/* optional examples
item.tags = [NSArray arrayWithObjects:#"bay bridge", #"architecture", #"california", nil];
//give a source rect in the coords of the view set with setRootViewController:
item.popOverSourceRect = [self.navigationController.toolbar convertRect:self.navigationController.toolbar.bounds toView:self.view];
*/
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
[SHK setRootViewController:self];
[actionSheet showFromToolbar:self.navigationController.toolbar];
}
You can also integrate FBConnect framework provide by Facebook.

Resources