Setup Remote Configurations
GameAnalytics' Remote Configurations
feature offers the ability to set up and tune values in your game's dashboard.
These values can be changed on the whim without needing to release a new version of the game.
The remote configs are a custom set of key-pair values.
Set up your Remote Configurations in the GameAnalytics dashboard.
Check Remote Config Updates in iOS
- Objective-C
- Swift
- (void) onRemoteConfigsUpdated
{
// add your code here
}
[GameAnalytics setRemoteConfigsDelegate:self];
func onRemoteConfigsUpdated() {
// add your code here
}
GameAnalytics.setRemoteConfigsDelegate(self)
Manual Check for Remote Config Updates
To manually check if Remote Configs are ready (if they have been populated with values from the server) you can use the following method:
- Objective-C
- Swift
if([GameAnalytics isRemoteConfigsReady])
{
// the remote configs is ready, add your code here
}
if GameAnalytics.isRemoteConfigsReady() {
// the remote configs is ready, add your code here
}
The isRemoteConfigsReady
function will return false if the configs haven't been populated by the server yet.
Retrieve Remote Config Values
After the remote configs have been populated you can retrieve their values by using the following function:
- Objective-C
- Swift
// Without custom default value (using normal default value)
NSString *value = [GameAnalytics getRemoteConfigsValueAsString:@"key"];
// With custom default value
NSString *valueWithCustomDefaultValue = [GameAnalytics getRemoteConfigsValueAsString:@"key" defaultValue:@"myDefaultValue"];
// Without custom default value (using normal default value)
let value = GameAnalytics.getRemoteConfigsValueAsString("key")
// With custom default value
let valueWithCustomDefaultValue = GameAnalytics.getRemoteConfigsValueAsString("key", defaultValue: "myDefaultValue")
If the specified key is not found in the Remote Configs it will return the default value of either “normal”
or “custom”
value.
For more information on Remote Configs go here.