Home Screen Shortcut

Implement the Home Screen Shortcut API to help players quickly return to your game. This API displays an in-game dialog that lets players create the following shortcuts:

  • Android: Players can create a shortcut to your game on their Android home screen.
  • Web: Players can pin your game to their Play list.

Android Experience

The Home Screen Shortcut API prompts the player to add a shortcut to your game on their Android home screen. The player can either add the shortcut automatically or drag the icon to their preferred location.

Web Experience

The Home Screen Shortcut API prompts the player to pin your game to their Play shortcuts. Your game will also be added to the player's list of pinned games and their game list.

API Reference

The Home Screen Shortcut API consists of the following methods of the GameFeaturesLibrary class.

canCreateShortcut method

Indicates whether your game can prompt the user to create a Home Screen shortcut.

public static void canCreateShortcut(
  Context context, 
  JSONObject parameters, 
  DaemonRequest.Callback callback)

createShortcut method

Prompts the user to create a Home Screen shortcut for your game. This method can be called only once per session.

public static void createShortcut(
  Context context, 
  JSONObject parameters, 
  DaemonRequest.Callback callback)

Example

The following example demonstrates how to use the GameFeaturesLibrary.canCreateShortcut method to determine whether your game can create a Home Screen shortcut.

GameFeaturesLibrary.canCreateShortcut( 
  Context context, 
  null,
  new DaemonRequest.Callback() { 
    @Override 
    public void onCompleted(GraphResponse response) { 
      if (response.getError() != null) {/*Handle the error.*/} 
      else {
        try { 
          JSONObject data = response.getJSONObject();
          boolean canCreateShortcut = data.getBoolean("canCreateShortcut");
          if (canCreateShortcut) {
            GameFeaturesLibrary.createShortcut( 
              Context context, 
              null,
              DaemonRequest.Callback callback)
          }
        } catch (JSONException e) {/*Handle the exception.*/}
      }
    }
  } 
)