Managed Google Play iframe

With the managed Google Play iframe, you can embed managed Google Play directly in your EMM console to offer customers a unified mobility management experience.

managed Google Play iframe
Figure 1. The managed Google Play iframe showing the Search apps page.

The iframe contains a title bar and an expandable side menu. From the menu, users can navigate to different pages:

  • Search apps: Allows IT admins to search for and browse Google Play apps, view app details, and select apps.
  • Private apps: Allows IT admins to publish and manage private apps for their enterprise.
  • Web apps: Allows IT admins to publish and distribute website shortcuts as apps.
  • Organize apps: Allows IT admins to configure how apps are organized in the Play Store app on their user's devices.

All pages are enabled in the iframe by default, but can be disabled individually (see Add the iframe to your console).


Features

This section describes the features available in the managed Google Play iframe. For information on how to embed the iframe and implement these features, see Add the iframe to your console.


Add the iframe to your console

Step 1. Generate a web token

To generate a web token that identifies the enterprise, call Enterprises.createWebToken. The following example shows how to retrieve the token using the Google Play EMM API Client Library for Java.

All pages in the iframe are enabled by default. When generating a web token, you can specify which page(s) to disable. The example below disables Private apps, Web apps, and Organize apps.

public AdministratorWebToken getAdministratorWebToken(
        String enterpriseId) throws IOException {
    AdministratorWebTokenSpec tokenSpec = new AdministratorWebTokenSpec();
    tokenSpec.setParent("https://my-emm-console.com");
    tokenSpec.setPlaySearch(new AdministratorWebTokenSpecPlaySearch());
    tokenSpec.setPrivateApps(new AdministratorWebTokenSpecPrivateApps().setEnabled(false));
    tokenSpec.setWebApps(new AdministratorWebTokenSpecWebApps().setEnabled(false));
    tokenSpec.setStoreBuilder(new AdministratorWebTokenSpecStoreBuilder().setEnabled(false));
    return androidEnterprise
        .enterprise()
        .createWebToken(enterpriseId, tokenSpec)
        .execute();
}

You need to include the returned token, along with other parameters, when rendering the iframe in your console.

Step 2. Render the iframe

Here's an example of how to render the managed Play iframe:

<script src="https://apis.google.com/js/api.js"></script>
<div id="container"></div>
<script>
  gapi.load('gapi.iframes', function() {
    var options = {
      'url': 'https://play.google.com/work/embedded/search?token=web_token&mode=SELECT',
      'where': document.getElementById('container'),
      'attributes': { style: 'width: 600px; height:1000px', scrolling: 'yes'}
    }

    var iframe = gapi.iframes.getContext().openChild(options);
  });
</script>

This code generates an iframe inside the container div. Attributes to be applied to the iframe tag can be set with the 'attributes' option, as above.

URL parameters

The table below lists all the available parameters for the iframe that can be added to the URL as URL parameters, e.g:

'url': 'https://play.google.com/work/embedded/search?token=web_token&mode=SELECT&showsearchbox=TRUE',
Parameter Page Required Description
token N/A Yes The token returned from Step 1.
iframehomepage N/A No The initial page displayed when the iframe is rendered. Possible values are PLAY_SEARCH, WEB_APPS, PRIVATE_APPS, and STORE_BUILDER (organize apps). If not specified, the following order of precedence determines which page is displayed: 1. PLAY_SEARCH, 2. PRIVATE_APPS, 3. WEB_APPS, 4. STORE_BUILDER.
locale N/A No A well-formed BCP 47 language tag that is used to localize the content in the iframe. If not specified, the default value is en_US.
mode Search apps No SELECT: lets IT admins select apps.
APPROVE (default): lets IT admins select, approve, and un-approve apps. This mode is deprecated, use SELECT instead. APPROVE mode only works if PlaySearch.ApproveApps is set to true in the web token.
showsearchbox Search apps No TRUE (default): displays the search box and initiates the search query from within the iframe.
FALSE: the search box is not displayed.
search Search apps No Search string. If specified, the iframe directs the IT admin to search results with the specified string.

Step 3. Handle iframe events

You should also handle the following events as part of your integration.

EventDescription
onproductselect The user selects or approves an app. This returns an object containing:
{
    "packageName": The package name of the app, e.g. "com.google.android.gm",
    "productId": The product ID of the app, e.g. "app:com.google.android.gm",
    "action": The type of action performed on the document. Possible values are:
    "approved", "unapproved" or "selected." If you implement the iframe in SELECT
    mode, the only possible value is "selected".
}
    
The sample below shows how to listen for onproductselect:
iframe.register('onproductselect', function(event) {
  console.log(event);
}, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);