Facebook Android SDK 4.1+
Facebook Android SDK 4.1+
我正在为 Facebook 升级到最新的 Android 和 iOS sdks,有两个问题。
现在我们有了必须定期刷新的 access token
的概念,我一直在阅读 iOS SDK 并注意到 SDK 中的以下内容:
/*!
@abstract Refresh the current access token's permission state and extend the token's expiration date,
if possible.
@param completionHandler an optional callback handler that can surface any errors related to permission refreshing.
@discussion On a successful refresh, the currentAccessToken will be updated so you typically only need to
observe the `FBSDKAccessTokenDidChangeNotification` notification.
If a token is already expired, it cannot be refreshed.
*/
+ (void)refreshCurrentAccessToken:(FBSDKGraphRequestHandler)completionHandler;
此方法用于刷新SDK,在classFBSDKAccessToken
中。在 Android 方面,我试图找出是否也是如此,并阅读代码和相关文档,它没有说明 AccessToken
class 的必须在到期前调用刷新方法 (refreshCurrentAccessTokenAsync
)。
我在文档中读到了这个:
https://developers.facebook.com/docs/reference/android/current/class/AccessToken/
即使是 getLastRefresh()
,它也表示如下:
Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK will attempt to renew them periodically.
这与 iOS 不同,后者不会自动刷新。我的假设正确吗? iOS 和 Android sdk 处理刷新的方式不同?
此外,刷新令牌的最佳做法是什么?我一直在 iOS 中的 didFinishLaunchingWithOptions
和 Android 中刷新令牌,我在应用程序加载时进行刷新。但是,如果有更多关于 SDK 最佳策略的信息,将会有所帮助。
我一直在阅读以下内容:
https://www.sammyk.me/access-token-handling-best-practices-in-facebook-php-sdk-v4
如果您发出图表请求,访问令牌将在 Android SDK 中自动刷新(它会搭载在您发出的请求上)。
我正在为 Facebook 升级到最新的 Android 和 iOS sdks,有两个问题。
现在我们有了必须定期刷新的 access token
的概念,我一直在阅读 iOS SDK 并注意到 SDK 中的以下内容:
/*!
@abstract Refresh the current access token's permission state and extend the token's expiration date,
if possible.
@param completionHandler an optional callback handler that can surface any errors related to permission refreshing.
@discussion On a successful refresh, the currentAccessToken will be updated so you typically only need to
observe the `FBSDKAccessTokenDidChangeNotification` notification.
If a token is already expired, it cannot be refreshed.
*/
+ (void)refreshCurrentAccessToken:(FBSDKGraphRequestHandler)completionHandler;
此方法用于刷新SDK,在classFBSDKAccessToken
中。在 Android 方面,我试图找出是否也是如此,并阅读代码和相关文档,它没有说明 AccessToken
class 的必须在到期前调用刷新方法 (refreshCurrentAccessTokenAsync
)。
我在文档中读到了这个:
https://developers.facebook.com/docs/reference/android/current/class/AccessToken/
即使是 getLastRefresh()
,它也表示如下:
Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK will attempt to renew them periodically.
这与 iOS 不同,后者不会自动刷新。我的假设正确吗? iOS 和 Android sdk 处理刷新的方式不同?
此外,刷新令牌的最佳做法是什么?我一直在 iOS 中的 didFinishLaunchingWithOptions
和 Android 中刷新令牌,我在应用程序加载时进行刷新。但是,如果有更多关于 SDK 最佳策略的信息,将会有所帮助。
我一直在阅读以下内容:
https://www.sammyk.me/access-token-handling-best-practices-in-facebook-php-sdk-v4
如果您发出图表请求,访问令牌将在 Android SDK 中自动刷新(它会搭载在您发出的请求上)。