如果您查看文档,也会看到提到替代api。
根据以下文件
FBSDKLoginManager
,上面写着:
- (void)logInWithReadPermissions:(NSArray *)permissions
handler:(FBSDKLoginManagerRequestTokenHandler)handler
__attribute__((deprecated("use logInWithReadPermissions: fromViewController:handler: instead")));
所以有一种新的方法,它需要一个额外的参数
UIViewController
以确定从何处启动登录序列。正如文件所述:
- (void)logInWithReadPermissions:(NSArray *)permissions
fromViewController:(UIViewController *)fromViewController
handler:(FBSDKLoginManagerRequestTokenHandler)handler;
对参数的解释是:
fromViewController
-要从中呈现的视图控制器。如果为零
最顶层视图控制器将自动确定为最佳
可能的
由于只有一个附加参数,您可以像这样将其添加到现有实现中:
FBSDKLoginManager().logInWithReadPermissions(["public_profile", "others"],
fromViewController:self //<=== new addition, self is the view controller where you're calling this method.
handler: { (result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
})
最新的xcode也会建议您在写作时,
logInWithReadPermissions
所有可用选项。