简体   繁体   English

为什么FBSDKAccessToken.currentAccessToken()在我的设备上返回nil,但是在iOS模拟器中可以正常工作?

[英]Why does FBSDKAccessToken.currentAccessToken() returns nil on my device but works fine in the iOS simulator?

In my IOS9 application I use the Facebook SDK 4.7.0 graph api to search for public places. 在我的IOS9应用程序中,我使用Facebook SDK 4.7.0图形api搜索公共场所。

I use the FBSDKApplicationDelegate in my apps delegate which I believe provides me with valid app access token (since I don't use any user specific data an application login is sufficient for me). 我在我的应用程序委托中使用FBSDKApplicationDelegate,我相信它为我提供了有效的应用程序访问令牌(因为我不使用任何用户特定数据,因此应用程序登录足以满足我的需要)。

When I call FBSDKAccessToken.currentAccessToken() in my ViewController to check if the token is valid I always succeed in the simulator but not when deployed on the real device. 当我在ViewController中调用FBSDKAccessToken.currentAccessToken()来检查令牌是否有效时,我总是会在模拟器中成功,但是在实际设备上部署时却不会成功。

Any suggestions? 有什么建议么?

I have followed the new ios9 guide and provided the additional info in my plist. 我遵循了新的ios9指南,并在我的plist中提供了其他信息。 Since my application is still in development my Facebook companion app (which holds my app id and secret) are still not available for general public. 由于我的应用程序仍在开发中,因此我的Facebook伴侣应用程序(包含我的应用程序ID和机密信息)仍然无法向公众开放。 Could this be a problem? 这可能是个问题吗?

for checking facebook permission..& give a permission...if permission exist then automatically get accesstoken other wise ask for login... 用于检查facebook权限..&授予权限...如果存在权限,则自动获得accesstoken其他明智的登录要求...

For Swift 对于斯威夫特

 var login: FBSDKLoginManager = FBSDKLoginManager()
login.logInWithReadPermissions(["public_profile", "email"], handler: { (result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in

  if (error != nil)
  {
        //Process error
   }
   else if result.isCancelled
   {
        //Handle cancellations
   }
  else
  {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if result.grantedPermissions.contains("email"){
            //Do work
   }
     }
   })

For Objective c: 对于目标c:

check Permission like this. 检查这样的权限。 following code use .. 以下代码使用..

if ([[FBSDKAccessToken currentAccessToken]hasGranted:@"email"])
   {
      // add your coding here after login call this block automatically.
   }
   else
   {

//login code  **//if accesstoken expired...then call this block**

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];

[loginManager logInWithReadPermissions:@[@"public_profile", @"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)




  }];

   }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使登录,Facebook iOS SDK FBSDKAccessToken.currentAccessToken()也为零? - Facebook iOS SDK FBSDKAccessToken.currentAccessToken() is nil even when logged in? FBSDKAccessToken.currentAccessToken()。userID有时返回Nil - FBSDKAccessToken.currentAccessToken().userID sometimes returning Nil 每次发现FBSDKAccessToken.currentAccessToken()为零 - FBSDKAccessToken.currentAccessToken() found nil every time 使用权限登录后,为什么[FBSDKAccessToken currentAccessToken]为零 - Why is [FBSDKAccessToken currentAccessToken] is nil after login in with permissions iOS / FBSDK-FBSDKProfile在设备上为零,在模拟器上可以正常工作 - iOS/FBSDK - FBSDKProfile is nil on device, works fine on simulator FBSDKProfile currentProfile是nil但是FBSDKAccessToken currentAccessToken有值 - FBSDKProfile currentProfile is nil but FBSDKAccessToken currentAccessToken has value 退出应用程序后,FBSDKAccessToken currentAccessToken为零 - FBSDKAccessToken currentAccessToken nil after quitting app Firebase 在 ios 模拟器上运行良好,但在真实设备上不起作用 - Firebase works fine on ios simulator but it does't work on real device 为什么tableview在iOS 6+模拟器上工作正常,但在iOS 5模拟器中它崩溃了 - Why does tableview works fine on iOS 6+ simulator but in iOS 5 simulator it crashes Google Maps SDK在物理设备中返回iOS错误,但在Simulator中可以正常工作 - Google Maps SDK returns iOS error in physical device but works fine in Simulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM