FBSessionTokenCachingStrategy class is responsible for persisting and retrieving cached data related to
an FBSession object, including the user's Facebook access token.
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
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
init method. This enables your application to control the key name used in
NSUserDefaults 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.
Direct use of
FBSessionTokenCachingStrategyis an advanced technique. Most applications use FBSession objects without
FBSessionTokenCachingStrategy, which yields default caching to
Helper function called by the SDK as well as apps, in order to fetch the default strategy instance.
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.
Dictionary containing token information to be validated
Called by FBSession (and overridden by inheritors), in order to cache token information.
Dictionary containing token information to be cached by the method
Called by FBSession (and overridden by inheritors), in order delete any cached information for the current token
Called by FBSession (and overridden by inheritors), in order to fetch cached token information
An overriding implementation should only return a token if it can also return an expiration date, otherwise return nil
Initializes and returns an instance
Specifies a key name to use for cached token information in NSUserDefaults, nil indicates a default value of @"FBAccessTokenInformationKey"