申请被授权后,IOS-Facebook空白屏幕

时间:2015-11-03 13:05:24

标签: ios facebook parse-platform facebook-ios-sdk

我正在从Parse v1.6.4升级到最新版本,我也正在将facebook ios sdk升级到v4.7。 问题是在应用程序被授权后,它显示一个空白的白色屏幕,如果我点击“完成”,它会关闭游侠,并在日志中显示,用户取消登录。
在将其升级到新版本之前,它工作正常。

  

我的plist

<key>CFBundleURLTypes</key>
 <array>
  <dict>
   <key>CFBundleURLSchemes</key>
 <array>
 <string>fbxxxxxx</string>
 </array>
 </dict>
</array>
<key>FacebookAppID</key>
<string><my FacebookAppID></string>
<key>FacebookDisplayName</key>
<string>my appname</string>
  

白名单FB服务器

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>
<key>fbcdn.net</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>
<key>akamaihd.net</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>

<key>LSApplicationQueriesSchemes</key>
 <array>
  <string>fbapi</string>
  <string>fb-messenger-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>
  

AppDelegate.m

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                         openURL:url
                                               sourceApplication:sourceApplication
                                                      annotation:annotation];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                    didFinishLaunchingWithOptions:launchOptions];
}
  

viewController.m

-(IBAction)facebookLogin:(id)sender
{
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

    if ([FBSDKAccessToken currentAccessToken])
    {
        //Do something

    }
    else
    {
        [login logInWithReadPermissions:@[@"email"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
         {
             if (error)
             {
                 NSLog(@"Error");
             }
             else if (result.isCancelled)
             {
                 NSLog(@"User cancelled login");
             }
             else
             {
                 NSLog(@"Login Success");

                 if ([result.grantedPermissions containsObject:@"email"])
                 {
                     NSLog(@"result is:%@",result);

                 }
                 else
                 {
                     NSLog(@"FB email permission error");

                 }
             }
         }];
    }
}

这是屏幕的图像。

enter image description here

我在我的iPhone 6设备上运行这个测试应用程序 谢谢! :)

  

编辑1:
  今天,我将我的项目升级到Facebook的新v4.8 SDk,这次,它似乎正在运作   我不确定,那时我做错了什么,但它现在正在为arm64设备工作     但是当我启用对armv7s的支持时,它给了我这个错误......

ld: file is universal (4 slices) but does not contain a(n) armv7s slice:

它指向FBSDKLoginKit.framework armv7s设备是否不再受支持?
反正有没有摆脱这个错误?
谢谢! :)

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,事实证明

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool 
在ios 9.0中已弃用。我也实现了方法

func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool 

所以FB SDK正在调用后者。 所以我必须确保在两种方法中都调用 FBSDKApplicationDelegate (一次用于ios 8,一次用于ios9)。

这是我对AppDelegate的实现:

 @available(iOS 9.0, *)
func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    let handled = FBSDKApplicationDelegate.sharedInstance().application(application,
                                                                        openURL: url,
                                                                        sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String,
                                                                        annotation: options [UIApplicationOpenURLOptionsAnnotationKey])
    if !handled {
        return self.openURL(url)
    }
    return true
}

@available(iOS, introduced=8.0, deprecated=9.0)
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    let handled = FBSDKApplicationDelegate.sharedInstance()
        .application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
    if !handled {
        return self.openURL(url)
    }
    return true
}

其中self.openURL(url)可用于处理facebook旁边的其他url类型。