header: <RaveSocial/RaveAppDataKeysManager.h>
class: RaveAppDataKeysManager
App data keys can be used to index cloud or other back-end storage data to a user’s account for a given application. App Data Keys are randomly generated IDs for each user in a 32 character hex format. When the user’s account is merged and both the source and target user of the merge have an active key for a game, the keys will enter an unresolved state and no key will be selected. This API provides the unresolved keys so that an application can provide a selection, either automatically (set by the developer) or via user input. Once a key is selected, the remaining unresolved keys will become rejected. Rejected keys can be selected at any time.
Any key in the list of all available can be selected at any time.
Note
Although the Rave SDK will work correctly in a case where no key is selected, we strongly recommend that the game ensures that a key is selected at all times during a game session. The reason is that when no key is selected, the player’s progress (or other important game data) is not indexed, and therefore progress could be lost. One way to do this is to check whether ADK is selected on game open, and during a network switch.
RaveAppDataKeysStateObserver#
Tip
Best Practice - Every application should be using this API to retrieve the selected app data key or resolve a selected key from the list of unresolved keys.
Implement RaveAppDataKeysStateObserver observer protocol when using the app data keys system to track save keys for cloud storage
appDataKeyStateChanged#
This method will be called after init to establish your current identity or if you are currently in an unresolved state. It will also be called when the system has detected that, after a merge, the current user has no selected app data key. This means that both users in the merge had a selected key and a determination needs to be made about which merged key should become the selected key. See RaveAppDataKeys(Manager) for details on retrieving the unresolved keys and selecting the valid key.
- (void)appDataKeyStateChanged:(NSString *)selectedKey unresolvedKeys:(NSArray *)unresolvedKeys;
Parameters:
selectedKey
- The key selected for this application and userunresolvedKeys
- Keys that need to be resolved, there will always be zero or two or more
Callbacks#
RaveAppDataKeysStateCallback#
Callback to provide all possible details for application data keys for this user and application:
typedef void (^RaveAppDataKeysStateCallback)(NSString * selectedKey, NSArray * rejectedKeys, NSArray * unresolvedKeys, NSError * error);
Parameters:
selectedKey
- The key selected for this application and userrejectedKeys
- Keys that have been rejected for use as the selected keyunresolvedKeys
- Keys that need to be resolved, there will always be zero or two or moreerror
- An error or nil
RaveAppDataKeysCallback#
Callback to fetch a subset of the app data keys information:
typedef void (^RaveAppDataKeysCallback)(NSArray * keys, NSError * error);
Parameters:
keys
- The array of requested keyserror
- An error or nil
RaveAppDataKeyCallback#
Callback to fetch the selected key:
typedef void (^RaveAppDataKeyCallback)(NSString * selectedKey, NSError * error);
Parameters:
selectedKey
- The app data key selected for the current usererror
- An error or nil
RaveAppDataKeysManager#
Manages app data keys
setStateObserver#
Set an instance of the appDataKeysStatusObserver:
- (void)setStateObserver:(id<RaveAppDataKeysStateObserver>)stateObserver;
Paramaters:
stateObserver
- Observer for changes in status
lastSelectedKey#
Cached last selected key, if any. When possible prefer key from state observer:
- (NSString *)lastSelectedKey;
Returns: Last selected app key or nil
fetchCurrentState#
Fetch the selected key, rejected keys, and unresolved keys for this application:
- (void)fetchCurrentState:(RaveAppDataKeysStateCallback)callback;
Parameters:
callback
- Provides information about data keys for the current application or an error
fetchUnresolved#
Fetch the set of unresolved keys, will either have a count of zero or two or more:
- (void)fetchUnresolved:(RaveAppDataKeysCallback)callback;
Parameters:
callback
- Callback supplying the keys or an error
fetchSelected#
Fetch the currently selected key for the user. Will be nil unless a key has been selected:
- (void)fetchSelected:(RaveAppDataKeyCallback)callback;
Parameters:
callback
- Callback supplying the selected key or an error
fetchAvailable#
Fetch values available to be used as keys - This list will included every Rave identity associated with the current account:
- (void)fetchAvailable:(RaveAppDataKeysCallback)callback;
Parameters:
callback
- Callback supplying the requested keys or an error
selectKey#
Change the selected key to the specified value:
- (void)selectKey:(NSString *)selectedKey callback:(RaveCompletionCallback)callback;
Parameters:
selectedKey
- The desired value of the new selected keycallback
- Callback suppyling an error or nil on success
deactivateKey#
Deactivates a key - Requires active network and only works for keys which are selected, rejected or unresolved:
- (void)deactivateKey:(NSString *)key callback:(RaveCompletionCallback)callback;
Parameters:
key
- The key to deactivate, must be 32 character hex formatcallback
- Callback suppyling an error or nil on success
fetchUserKey#
Returns an App Data Key when given a UUID. Essentially a lookup based on UUID:
- (void)fetchUserKey:(NSString *)raveId callback:(RaveAppDataKeyCallback)callback;
Parameters:
raveId
- The user’s raveID you wish to look upcallback
- A callback to be called when the operation completes. Contains a selected key or an error
fetchUserKeySet#
Fetch a set of keys given an array of RaveIDs:
- (void)fetchUserKeySet:(NSArray <NSString *>*)raveIds callback:(RaveAppDataKeySetCallback)callback;
Parameters:
raveIds
- A List of desired Rave IDscallback
- A callback supplying a list of app data keys or an error
fetchUserKeySetForContacts#
Fetch the current user’s contacts app data keys:
- (void)fetchUserKeySetForContacts:(RaveAppDataKeySetCallback)callback;
Parameters:
callback
- a callback to be called when the operation completes. Contains an array of app data key and rave ID pairs or an error