Trong ứng dụng của tôi có một tùy chọn để đăng nhập bằng Facebook.Mục tiêu c - iOS 10 Đăng nhập Facebook màn hình trống
Trên iOS 9.3, nó hoạt động OK.
Khi tôi thử nghiệm trên iOS 10.0.1, nó hiển thị cho tôi một màn hình trống.
Tôi đang sử dụng mã này để bắt đầu quá trình đăng nhập:
- (void)FacbookLoginButtonPressed:(id)sender {
[self showLoader];
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile", @"email"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else if (result.isCancelled) {
NSLog(@"Cancelled");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else {
[self loginButton:sender didCompleteWithResult:result error:error];
NSLog(@"Logged in");
}
}];
}
self
là ViewController tôi gọi loginViewController
hiển thị nút, nó kế thừa từ UIViewController
Ứng dụng của tôi sử dụng thư viện này cho điều hướng trang trình bày: https://github.com/aryaxt/iOS-Slide-Menu
Có hai tùy chọn để hiển thị màn hình loginViewController
:
1. Từ màn hình thường xuyên (kế thừa từ UIViewController
), có một nút, mà trên nhấp chuột mã này chạy:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"loginScreen";
[self presentViewController:vc animated:YES completion:nil];
của làm việc tốt đó, tôi có thể đăng nhập với Facebook thành công.
2. Từ màn hình khác cũng kế thừa từ UIViewController
, nhưng màn hình này là menu trượt, và tôi có mã này trong AppDelegate
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MenuViewController *menu = [sb instantiateViewControllerWithIdentifier:@"MenuViewController";
[SlideNavigationController sharedInstance].rightMenu = menu;
Sử dụng tùy chọn này, facebook đăng nhập không hoạt động (màn hình trống)
hành động mà tôi đã làm để cố gắng làm cho nó hoạt động:
- cập nhật vào facebook SDK mới nhất - usin g này: https://developers.facebook.com/docs/ios/getting-started
- Bật chia sẻ keychain - sử dụng này: https://stackoverflow.com/a/38799196/867694
Điều duy nhất mà tôi có trong nhật ký khi loginViewController
xuất hiện từ thực đơn (tùy chọn thứ 2) là thế này:
Presenting view controllers on detached view controllers is discouraged <loginViewController: 0x7622fb0>.
Tôi có thể làm gì?
Vấn đề là trong cách trình bày SafariViewController. Trong iOS 10 Apple đã thêm một số mã để cấm sử dụng SafariVC ẩn (tôi đã viết về điều này [ở đây] (http://stackoverflow.com/questions/39019352/ios10-sfsafariviewcontroller-not-working-when-alpha-is-set- to-0)) và có vẻ như nó kích thích hành vi của bạn. Kiểm tra [answer] (http://stackoverflow.com/a/39386491/1044073) cho câu hỏi tương tự, nó có thể gợi ý cho bạn một giải pháp. –