在向应用提供权限后,我没有收到来自facebook的任何回调。应用程序只是打开fb浏览器,请求权限然后卡在页面上。我的fb App已经单点登录,并且对一般公共用途有效。我还在那里提供了我的包标识符。
您可以在此处查看我的AppDelegate配置:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if ([[GPPSignIn sharedInstance] authentication]) {
NSLog(@"User is logged In already");
}else{
NSLog(@"User is not logged In already");
}
//return YES;
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[FBSDKAppEvents activateApp];
}
#pragma mark - Social callback Delegates
- (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
defaults = [NSUserDefaults standardUserDefaults];
BOOL urlStatus;
NSString *socialNetwork = [defaults objectForKey:@"socialNetwork"];
if([socialNetwork isEqualToString:@"google"])
{
urlStatus = [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
else if([socialNetwork isEqualToString:@"facebook"])
{
urlStatus = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
return urlStatus;
}
我的登录方法如下所示:
-(void) loginWithFacebook
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[defaults setObject:@"facebook" forKey:@"socialNetwork"];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error || result.isCancelled)
{
// Process error
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
else
{
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:@"email"])
{
// Do work
isValid = YES;
[self performSegueWithIdentifier:@"LoginWithFacebook" sender:self];
}
}
}];
}
以下是.plist
和链接库的图像。
屏幕截图中没有URL标识符,但我添加了它。 你能告诉我我做错了什么吗?或者可能缺少什么?
答案 0 :(得分:2)
检查这2个方法
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[FBAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBSession.activeSession handleOpenURL:url];
}