- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在关注 Facebook's own tutorial对于 iOS (Objective-C) 中的 FB 登录,但每次我登录时 - 在初始权限授权屏幕之后 - 我都会收到臭名昭著的“您已经授权此应用程序” WebView 。
我已经阅读了大量的帖子,但我无法将其整理出来,因此(重新)发布。我觉得这很奇怪,因为该应用程序除了样板登录代码外什么都没有。这种行为在模拟器和真实设备中都会发生。
此应用适用于 iOS 9.0,我使用的是 FBSDK 4.7.1(通过 CocoaPods 安装):
pod 'FBSDKLoginKit', '~> 4.6'
代码本身就是样板文件,这是我的 AppDelegate.m:
#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
@end
和我的 ViewController.m:
#import "ViewController.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
[loginButton setLoginBehavior:FBSDKLoginBehaviorSystemAccount]; // No difference
loginButton.center = self.view.center;
[self.view addSubview:loginButton];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
以及 Info.plist 的屏幕截图:
最后,我还在控制台中收到了这两个错误:
2015-11-24 11:50:42.855 lixo[26941:389756] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2015-11-24 11:50:42.860 lixo[26941:389756] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
尽管根据我的阅读,如果在 Info.plist 中设置了 LSApplicationQueriesSchemes,则可以安全地忽略它。
有什么办法可以避免这种情况吗?
最佳答案
您可以检查访问 token 的状态,而不是在每次启动时触发登录。如果未过期,则跳过登录,直接开始使用 API。可以使用以下方法检查 token 是否过期:
+(BOOL) accessTokenIsLocalyValid
{
return [FBSDKAccessToken currentAccessToken] && [[NSDate date] compare:[FBSDKAccessToken currentAccessToken].expirationDate] == NSOrderedAscending;
}
如果您有一个有效的 token ,您可以使用 [FBSDKAccessToken refreshCurrentAccessToken:]
刷新它。
关于ios - FBSDK 4.7.1登录时"You have already authorized yourApp",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33893338/
我正在尝试构建一个 react-native ios 应用程序。我正在尝试从 curl -O https://raw.githubusercontent.com/facebook/react-nati
在安装 fbsdk 库并按照所有步骤正确链接它之后,我在使用 react-native run-android 构建我的 android 文件夹时遇到问题。以下是我的错误消息。 我已经尝试将我的默认
我正在 Swift 应用程序中通过 Facebook 编写登录。我下载了 FacebookSDK,链接了库并创建了桥接 header ,并将其添加到 Objective-C 桥接 header 中。其
我正在用 swift 编写一个项目,我对这门语言还很陌生。 我将变量“username”的值设置为我对 facebook sdk 的请求结果,但在图形请求后我的变量值变为 nil。变量赋值在图形请求本
我目前正在为我的应用程序实现 Facebook 登录,我正在尝试从配置文件中获取以下信息: 名字,姓,性别,和国家。 但是,我似乎只能获取除用户国家以外的所有内容。我试过像这样将我的参数设置到我的 F
运行命令 react-native run-android 或 ./gradlew build 时出现以下错误 :react-native-fbsdk:generateReleaseResValues
我这样做了: react-native init YourApp cd YourApp react-native install react-native-facebooksdk react-nati
在我的图像处理应用程序中,我尝试使用 Facebook Profile Expression Kit。调用方法后 [FBSDKProfileExpressionSharer uploadProfile
FBSDKAccessToken currentAccessToken nil after quitting app 我看了很多相关的线程,我的案例中的解决方案仍然难以辨认。 这是我的 AppDele
分享静态照片时,我可以让我的应用程序切换到 Facebook 来分享该图像。它似乎与视频不一样。 这分享一张照片就好了。它移动到 Facebook 应用程序以确认帖子: let sharePhoto
我正在设置使用 facebook 登录,我想做的是当用户第一次授权该应用程序时,他们会转到一个新的 VC,在那里他们选择一个用户名。 但是,如果该用户注销然后再次使用 facebook 登录,我不希望
我们在模拟器中遇到应用程序传输安全错误(在 OSX 10.10.5 上运行的 Xcode 7)。我们为 iOS9 实现了 FB 指南。 调用的FB graph api是基于SDK v.3.24的。 在
我想在 Facebook 上分享图片,为此我这样做了: let photo: FBSDKSharePhoto = FBSDKSharePhoto() photo.image = croppedImag
根据标题,在我的设备上测试时,我收到 nil 可选展开错误,但在模拟器上却没有 - 我发现此问题的原因是调用 FBSDKProfile.currentProfile.name或类似的。我记得这给我在模
onLoginFinished 的结果只是告诉我授予的权限。来自repo ,不清楚如何获取用户配置文件。似乎 react-native-fbsdkcore 应该包装 FBSDKProfile.h 但看
我正确设置了 Facebook 登录(我能够使用 Facebook 按钮登录并检索个人资料数据)。我按照 FB 开发人员指南设置了 SSK 和登录按钮。当我返回按钮并想注销时出现问题。这是我得到的:
我设置了与 FB 开发者页面相同的所有内容(appId、appName、bundleId...)。我在 FBSDK 4.6 和 iOS 9 上工作。我也已经在 info.plist 上添加了这个 ke
我需要在 react-native 中处理 Facebook 登录错误。 在我的应用程序全新安装后尝试登录会向用户显示弹出窗口: "Facebook. Application would like t
我已经集成了 react-native-fbsdk 库并获取用户个人资料信息,例如除电子邮件之外的姓名、中间名等 我已经尝试过 readPermissions={["email,"public_pro
不要将其作为重复问题,我提出这个问题是因为答案没有帮助,集成对我来说效果很好,但页面加载速度非常慢。 加载登录屏幕确实需要很长时间。登录操作需要超过 8-50 秒或更长时间。 有时加载验证屏幕需要超过
我是一名优秀的程序员,十分优秀!