To display permission page on facebook iphone

I am new to iphone development, I want to display permission page after login to facebook.

buttonIndex is the index of my action tables.

if(buttonIndex == 1) { session = [FBSession sessionForApplication:@"My App key" secret:@"My Key" delegate:self]; FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:session] autorelease]; [dialog show]; } 

using this code successfully loggin for facebook, but I want the permission page to display,

so i can use

  - (void)session:(FBSession*)session didLogin:(FBUID)uid { NSLog(@"User with id %lld logged in.", uid); FBPermissionDialog* dialog1 = [[[FBPermissionDialog alloc] init] autorelease]; dialog1.delegate = self; dialog1.permission = @"uid"; [dialog1 show]; } 

But it does not work. Where can I put this code. And I want to share my content after permission.

If I log out of facebook, it goes to the browser, but I want to return my application after logging out,

Please help me, advise me plz.

+4
source share
2 answers

I would change this dialog1.permission = @"uid"; to something like this dialog1.permission = @"publish_stream"; . Since you want to publish your content in a user stream, right?

  - (void)session:(FBSession*)session didLogin:(FBUID)uid 

After logging in, I checked first, maybe you already have permission to publish to the user stream by creating FBRequest

 NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: @"publish_stream", @"ext_perm", nil]; [[FBRequest requestWithDelegate:self] call:@"facebook.users.hasAppPermission" params:params]; 

The result that you can evaluate here

 - (void)request:(FBRequest*)request didLoad:(id)result 

eg. like this

 if ([request.method isEqualToString:@"facebook.users.hasAppPermission"]) { NSString *success = result; if ([success isEqualToString:@"1"]) { NSLog(@"User has app permission"); // publish content now ... } else { // else ask for permission, opening permission dialog ... } 
+2
source

I highly recommend this training guy, Brandon Treb, on Facebook integration. He makes a very thorough presentation and takes you one at a time, so if it doesn't work, it's a typo on your part. His textbook made me work and work in less than two hours.

http://brandontreb.com/

0
source

Source: https://habr.com/ru/post/1301703/


All Articles