1

My application requires a "Like Us on Facebook" functionality.I tried to use Facebook SDK and the "FBLikecontrol" of the SDK.This is the code i tried:

 FBLikeControl *likeControl = [[FBLikeControl alloc] initWithFrame:CGRectMake(138, 270, 180, 40)]; [likeControl setObjectID:@"facebook page url"]; [likeControl setLikeControlStyle:FBLikeControlStyleStandard]; [[self view] addSubview:likeControl]; 

On running on the device(iOS7),when clicked on the like button,app redirects to the safari Facebook page and suddenly redirects backs to the app.Facebook page or nothing is showing.Can anyone help on this? Thanks in advance!

2
  • Can you paste the URL you want to like here? If you test it with other urls, non-Facebook-Page urls, does it work correctly? Commented Oct 19, 2014 at 17:59
  • It seems not working even with non-Facebook page urls. Commented Oct 20, 2014 at 7:18

3 Answers 3

4
+50

I tried your provided code in my Sample Application it working fine

FBLikeControl *fbLikeControlView = [[FBLikeControl alloc] initWithFrame:CGRectMake(100, 100, 200, 30)]; fbLikeControlView.likeControlStyle = FBLikeControlStyleStandard; fbLikeControlView.objectID=@"https://www.example.com/"; [self.view addSubview:fbLikeControlView]; 

My code is same as on facebook developer site Like Button iOS

Also don't forget to handle openURL method in Appdelegate

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { // Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication]; // You can add your app-specific url handling code here if needed return wasHandled; } 
Sign up to request clarification or add additional context in comments.

8 Comments

If it would not work, check If app registered as a URL Scheme.
The app is registered in the URL scheme also.But no luck!if your sample code is working,can i get that?Cant able to figure out what the issue is.
Sure I'll share you link soon with that sample, Also once check facebook sdk version.
It will be great if u can share it.Anyways i am using the latest SDK version available in the developer site.
|
4

I am follow these steps and its working...

Step 1- Add Facebook button to your view

FBLikeControl *like = [[FBLikeControl alloc] init]; like.objectID = @"https://www.facebook.com/{sub url}"; like.likeControlStyle = FBLikeControlStyleButton; like.objectType = FBLikeControlObjectTypePage; cell.accessoryView = like; 

Step 2- Send for Review (Important Step) Native Like button will work if you submit it for review from Facebook app. Go to your Facebook app page --> Status and Review and send like button for review.

if you are not follow second step you will face redirect problem.

Comments

0

4.28.0 - November 7, 2017 Facebook SDK The Native Like Button has been deprecated. link

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.