header: RaveAppDataKeyManager.cs
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 delegate 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.
public delegate void RaveAppDataKeysStateObserver(string selectedKey, List<string> unresolvedKeys);
Parameters:
selectedKey
- The key selected for this application and user
unresolvedKeys
- 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:
public delegate void RaveAppDataKeysStateCallback(string selectedKey, List<string> rejectedKeys, List<string> unresolvedKeys, string error);
Parameters:
selectedKey
- The key selected for this application and user
rejectedKeys
- Keys that have been rejected for use as the selected key
unresolvedKeys
- Keys that need to be resolved, there will always be zero or two or more
error
- An error or null
RaveAppDataKeysCallback#
Callback to fetch a subset of the app data keys information:
public delegate void RaveAppDataKeysCallback(List<string> keys, string error);
Parameters:
keys
- The array of requested keys
error
- An error or null
RaveAppDataKeyCallback#
Callback to fetch the selected key:
public delegate void RaveAppDataKeyCallback(string selectedKey, string error);
Parameters:
selectedKey
- The app data key selected for the current user
error
- An error or null
RaveAppDataKeysManager#
Manages app data keys
SetStateObserver#
Set an instance of the appDataKeysStatusObserver:
public void SetStateObserver(RaveAppDataKeysStateObserver stateObserver);
Paramaters:
stateObserver
- Observer for changes in status
LastSelectedKey#
Cached last selected key, if any. When possible prefer key from state observer:
string LastSelectedKey();
Returns: Last selected app key or null
FetchCurrentState#
Fetch the selected key, rejected keys, and unresolved keys for this application:
public 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:
public void FetchUnresolved(RaveAppDataKeysCallback callback);
Parameters:
callback
- Callback supplying the keys or an error
FetchSelected#
Fetch the currently selected key for the user. Will be null unless a key has been selected:
public 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:
public void FetchAvailable(RaveAppDataKeysCallback callback);
Parameters:
callback
- Callback supplying the requested keys or an error
SelectKey#
Change the selected key to the specified value:
public void SelectKey(string selectedKey, RaveCompletionCallback callback);
Parameters:
selectedKey
- The desired value of the new selected key
callback
- Callback suppyling an error or null on success
DeactivateKey#
Deactivates a key - Requires active network and only works for keys which are selected, rejected or unresolved:
public void DeactivateKey(string key, RaveCompletionCallback callback);
Parameters:
key
- The key to deactivate, must be 32 character hex format
callback
- Callback suppyling an error or null on success
fetchUserKey#
Returns an App Data Key when given a UUID. Essentially a lookup based on UUID:
- public static void FetchUserKey(string raveId, 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:
- public static void FetchUserKeySet(List<string> raveIds, 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:
- public static 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