Search code examples
iosiphonefacebookauthenticationappstore-approval

iPhone app rejection 17.2: app requires users sign in with their Facebook accounts


I followed the login instructions for my native iOS app here https://developers.facebook.com/docs/mobile/ios/build/

I have everything facebook in the AppDelegate in application:didFinishLaunchingWithOptions:

facebook = [[Facebook alloc] initWithAppId:@"xyzabc" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if ([defaults objectForKey:@"FBAccessTokenKey"] 
    && [defaults objectForKey:@"FBExpirationDateKey"]) {
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}


if (![facebook isSessionValid]) {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"publish_stream", 
                            nil];
    [facebook authorize:permissions];

}

The problem is that my app opens and I require people to be logged in to facebook to use the features in my app. Apple rejected me saying the Facebook feature should be optional rather than forced (listed under rejection reason 17.2).

I was just wondering if I can keep most everything in the app delegate, but put the

    if (![facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"publish_stream", 
                                nil];
        [facebook authorize:permissions];
}

somewhere else (like when a login to facebook button is pressed). If this is the case, should the facebook documentation be updated so no one else gets rejected? Or maybe I missed something where I can keep that in the app delegate, but call something else to make login optional?

Thanks in advance for your help!


Solution

  • What I did to solve this is I moved all the Facebook code from -applicationDidFinishLaunching to a custom method -createFBInstance that I called from a UIViewController whenever a UIButton was pressed so now the user only logs in to Facebook when a button is clicked and the app works great! Just make sure you only use the methods from the FBSessionDelegate inside your delegate I could never make it work in any other class. I also opened up the login web page in a web view inside the app so it looks much nicer.