FBSessionTokenCachingStrategy
คลาสนี้ไม่มีให้ใช้งานใน SDK เวอร์ชั่นล่าสุดอีกต่อไป
เวอร์ชั่นที่ใหม่กว่าของคลาสนี้พร้อมแล้ว ตรวจสอบได้ เวอร์ชั่นล่าสุด

The FBSessionTokenCachingStrategy class is responsible for persisting and retrieving cached data related to an FBSession object, including the user's Facebook access token.

Discussion:

FBSessionTokenCachingStrategy is designed to be instantiated directly or used as a base class. Usually default token caching behavior is sufficient, and you do not need to interface directly with FBSessionTokenCachingStrategy objects. However, if you need to control where or how FBSession information is cached, then you may take one of two approaches.

The first and simplest approach is to instantiate an instance of FBSessionTokenCachingStrategy, and then pass the instance to FBSession class' init method. This enables your application to control the key name used in the iOS Keychain to store session information. You may consider this approach if you plan to cache session information for multiple users.

The second and more advanced approached is to derive a custom class from FBSessionTokenCachingStrategy, which will be responsible for caching behavior of your application. This approach is useful if you need to change where the information is cached, for example if you prefer to use the filesystem or make a network connection to fetch and persist cached tokens. Inheritors should override the cacheTokenInformation, fetchTokenInformation, and clearToken methods. Doing this enables your application to implement any token caching scheme, including no caching at all (see [FBSessionTokenCachingStrategy nullCacheInstance].

Direct use of FBSessionTokenCachingStrategyis an advanced technique. Most applications use FBSession objects without passing an FBSessionTokenCachingStrategy, which yields default caching to the iOS Keychain.

Inherits from:NSObject
Declared in:FBSessionTokenCachingStrategy.h
วิธีการคลาส
defaultInstance

Helper function called by the SDK as well as apps, in order to fetch the default strategy instance.

+ (FBSessionTokenCachingStrategy *) defaultInstance;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
isValidTokenInformation:

Helper function called by the SDK as well as application code, used to determine whether a given dictionary contains the minimum token information usable by the FBSession.

พารามิเตอร์คำอธิบาย
tokenInformation

Dictionary containing token information to be validated

+ (BOOL) isValidTokenInformation:(NSDictionary *)tokenInformation;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
nullCacheInstance

Helper function to return a FBSessionTokenCachingStrategy instance that does not perform any caching.

+ (FBSessionTokenCachingStrategy *) nullCacheInstance;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
วิธีการทันใจ
cacheFBAccessTokenData:

Cache the supplied token.

พารามิเตอร์คำอธิบาย
accessToken

The token instance.

- (void) cacheFBAccessTokenData:(FBAccessTokenData *)accessToken;
Discussion:

This essentially wraps a call to cacheTokenInformation so you should override this when providing a custom token caching strategy.

ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
cacheTokenInformation:

Called by FBSession (and overridden by inheritors), in order to cache token information.

พารามิเตอร์คำอธิบาย
tokenInformation

Dictionary containing token information to be cached by the method

- (void) cacheTokenInformation:(NSDictionary *)tokenInformation;
Discussion:

You should favor overriding this instead of cacheFBAccessTokenData only if you intend to cache additional data not captured by the FBAccessTokenData type.

ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
clearToken

Called by FBSession (and overridden by inheritors), in order delete any cached information for the current token

- (void) clearToken;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
fetchFBAccessTokenData

Fetches the cached token instance.

- (FBAccessTokenData *) fetchFBAccessTokenData;
Discussion:

This essentially wraps a call to fetchTokenInformation so you should override this when providing a custom token caching strategy.

In order for an FBSession instance to be able to use a cached token, the token must be not be expired (see +isValidTokenInformation:) and must also contain all permissions in the initialized session instance.

ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
fetchTokenInformation

Called by FBSession (and overridden by inheritors), in order to fetch cached token information

- (NSDictionary *) fetchTokenInformation;
Discussion:

An overriding implementation should only return a token if it can also return an expiration date, otherwise return nil. You should favor overriding this instead of fetchFBAccessTokenData only if you intend to cache additional data not captured by the FBAccessTokenData type.

ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
init

Initializes and returns an instance

- (instancetype) init;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h
initWithUserDefaultTokenInformationKeyName:

Initializes and returns an instance

พารามิเตอร์คำอธิบาย
tokenInformationKeyName

Specifies a key name to use for cached token information in the iOS Keychain, nil indicates a default value of @"FBAccessTokenInformationKey"

- (instancetype) initWithUserDefaultTokenInformationKeyName:(NSString *)tokenInformationKeyName;
ให้คำรับรองไว้ใน: FBSessionTokenCachingStrategy.h