Facebook iOS SDK - How can I make a Page Like Button works?

1k views Asked by At

I am trying to use FBSDKLikeControl / FBSDKLikeButton to let users like my Fan Page.

I tried in their sample code and it works on any Fan Pages. However, when I change the FacebookAppID into mine, it breaks. When I click the Like Button, the app navigates me to Facebook app and then switches back immediately.

- (void)viewDidLoad
{
  [super viewDidLoad];

  self.pageLikeControl.likeControlAuxiliaryPosition = FBSDKLikeControlAuxiliaryPositionBottom;
  self.pageLikeControl.likeControlHorizontalAlignment = FBSDKLikeControlHorizontalAlignmentCenter;
    self.pageLikeControl.objectID = @"burgerking";

}

plist file settings: plist file settings When I change above URL Schemes and FacebookAppID, the like function will fail.

Is it a permission problem on my app setting? I have not submitted any items to review yet as such login permission("public_actions").

Many Thanks!

1

There are 1 answers

1
hpDev_iOS On BEST ANSWER

Yes, You have to register your app with Facebook Developer and for now u no need to review your iOS app to Facebook as its in developing mode.

As u register your app with Facebook you will get instruction how to config your .plist of iOS app for connect with facebook.

Example Code :

FBSDKLikeControl *button = [[FBSDKLikeControl alloc] init];
button.objectID = @"https://www.facebook.com/FacebookDevelopers";
[self.view addSubview:button];

In the above code u just have to replace button.objectID Value with your Facebook post/page URL. I hope this will be Help full to u.

For More Refer : https://developers.facebook.com/docs/sharing/ios