Ale*_*lex 6 facebook ios facebook-ios-sdk parse-platform
我正在从Parse v1.6.4升级到最新版本,我也正在将facebook ios sdk升级到v4.7.问题是在应用程序被授权后,它显示一个空白的白色屏幕,如果我点击"完成",它会关闭Safari并在日志中显示用户取消登录.
在将其升级到新版本之前,它工作正常.
我的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>
Run Code Online (Sandbox Code Playgroud)
白名单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>
Run Code Online (Sandbox Code Playgroud)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Run Code Online (Sandbox Code Playgroud)
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];
}
Run Code Online (Sandbox Code Playgroud)
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");
}
}
}];
}
}
Run Code Online (Sandbox Code Playgroud)
这是屏幕的图像.
我在我的iPhone 6设备上运行这个测试应用程序.
谢谢!:)
编辑1:
今天,我将我的项目升级到Facebook的新v4.8 SDk,这一次,它似乎正在运作.
我不确定,那时我做错了什么,但它现在正在为arm64设备工作.
但是当我启用对armv7s的支持时,它给了我这个错误......
ld: file is universal (4 slices) but does not contain a(n) armv7s slice:
Run Code Online (Sandbox Code Playgroud)
它指向FBSDKLoginKit.framework.
armv7s设备是否不再受支持?
反正有没有摆脱这个错误?
谢谢!:)
我遇到了同样的问题,结果是
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
Run Code Online (Sandbox Code Playgroud)
在 ios 9.0 中已弃用。我也实现了该方法
func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool
Run Code Online (Sandbox Code Playgroud)
所以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
}
Run Code Online (Sandbox Code Playgroud)
其中 self.openURL(url) 可用于处理 facebook 之外的其他 url 类型。
| 归档时间: |
|
| 查看次数: |
2363 次 |
| 最近记录: |