简体   繁体   中英

iOS: Facebook Login error

There is always an error when trying to login via my ios app:

- (void)viewDidLoad
{

    FBLoginView *loginView = [[FBLoginView alloc] init];
    // Align the button in the center horizontally
    loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x - (loginView.frame.size.width / 2)), 25);
    loginView.delegate = self;
//loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];
    loginView.readPermissions = @[@"basic_info", @"email", @"user_likes", @"user_events",  @"user_videos", @"user_subscriptions", @"user_photos"];
    loginView.publishPermissions = @[@"manage_friendlists", @"manage_notifications", @"photo_upload", @"manage_pages", @"publish_stream", @"read_friendlists", @"read_mailbox", @"read_requests", @"read_stream", @"share_item", @"video_upload"];

    [self.view addSubview:loginView];


    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

Error:

Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: Publish permissions were requested without specifying an audience; use FBSessionDefaultAudienceJustMe, FBSessionDefaultAudienceFriends, or FBSessionDefaultAudienceEveryone'

What can i do to solve this error?

You have to specify the defaultAudience

@property (nonatomic, assign) FBSessionDefaultAudience defaultAudience;

The default audience to use, if publish permissions are requested at login time.

Add:

loginView.defaultAudience = FBSessionDefaultAudienceJustMe;

Or any from the following: FBSessionDefaultAudienceJustMe , FBSessionDefaultAudienceFriends , or FBSessionDefaultAudienceEveryone

Source: https://developers.facebook.com/docs/reference/ios/current/class/FBLoginView/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM