Jump to: navigation, search

App Parameters

Using App Parameters

App Parameters is a feature that allows you to change the value of certain variables in your game without the need for iterative and time consuming updates. The app parameters for your game are stored on Fuse servers and can be updated at any time via the App Parameters page in the Fuse dashboard. App parameters can be customized for any segment by using the Custom App Experiences feature.

To start using App Parameters, navigate to the "App Params" tab of the "CONFIGURE" page for your game. (if you don't see the App Params tab, please contact your account manager or email us at support@fusepowered.com)

You can add a parameter by pressing the Add Parameter button at the bottom of the list. Once you have created a new parameter simply click the Key or the Value to select and input your data. Make sure all App Parameters you intend to use are Enabled.

App params.png

After the parameters have been set it's time to implement them into your code. There are two ways to get the data from the server, the first way is to call for a value corresponding to a specific key, as shown:

iOS:

  NSString *my_val = [FuseAPI getGameConfigurationValue:@"my_key"];

Android:

  String *my_val = FuseAPI.getGameConfigurationValue("my_key");

and the second is to get all the parameters into a dictionary which is:

iOS:

  NSMutableDictionary *my_vals = [FuseAPI getGameConfiguration];

Android:

  Dictionary<String, String> my_vals = FuseAPI.getGameConfiguration();

Note that the above methods can be called even if a Fuse session has not been started. This is to allow your game access to the latest parameter values that had been retrieved and stored by the Fuse SDK. When the Fuse SDK initializes and has a valid connection to the Fuse servers (i.e. the device has internet), the app parameters will be automatically downloaded to the device.

Values are updated in the client each time a session is started from the Springboard or system tray. To find out when values are valid, you can use the following FuseDelegate callback method that indicates when the values are ready to be inspected.

iOS:

  Bool has_game_config_returned = NO;
  -(void) gameConfigurationReceived{
    has_game_config_returned = YES;
    NSMutableDictionary *my_vals = [FuseAPI getGameConfiguration];
    if (my_vals != nil && [my_vals count] > 0)
    {
      NSArray *keys = [my_vals allKeys];
      for (int i = 0; i < [keys count]; i++)
      {
        NSString *key = [keys objectAtIndex:i];
        NSString *value = [my_vals objectForKey:key];
        NSLog(@"Key: %@, Value :%@", key, value);
      }
    }
  }

Android:

  bool has_game_config_returned = false;
  -(void) gameConfigurationReceived
  {
    has_game_config_returned = true;
      
    // You can now access your updated server-side data, either here or somewhere else in your code
    HashMap<String, String> my_vals = FuseAPI.getGameConfiguration();
    if (my_vals != null && my_vals.size() > 0)
      {
        Set<String> keySet = my_vals.keySet();
        String[] keys = (String[]) keySet.toArray();
        for( int i = 0; i < keys.length; i++ )
          {
            String key = keys[i];
            String value = my_vals.get(key);
       
            Log.d(TAG, "Key: " + key + ", Value: " + value); 
          }
      }
  } 

Now that you have the Parameters in code, you can assign them how you want.


NoteBubble.png

It is a good idea to both check the variables against nil to see if they are working as expected, as well as Initialize all the variables in your code in case the user has never connected to the internet.