Class

MediaPermission

MediaPermission

Example

Draw visitor's attention to media permission prompt

  function showArrowsPointingToPermissionPrompt(response) {
    // Your code
  }

  function hideArrowsPointingToPermissionPrompt(response) {
    // Your code
  }

  var engagementRequest = salemove.requestEngagement('text');

  engagementRequest.engagementPromise.then(function(engagement) {
    var handleMediaPermissionRequest = function(request) {
      showArrowsPointingToPermissionPrompt();
      request.responsePromise.then(function(response) {
        hideArrowsPointingToPermissionPrompt();

        if (response === 'allowed') {
          // Handle Visitor allowed access to media device
        }

        if (response === 'denied') {
          // Handle Visitor denied access to media device
        }
      }).catch(function(error) {
        // Handle error
      });
    };

    engagement.addEventListener(
      engagement.EVENTS.MEDIA_PERMISSION_REQUEST,
      handleMediaPermissionRequest
    );
  });

Members

Promise

# responsePromise

Fulfilled with a String response or rejected with an Error if the process fails for any reason. In case of a fulfilled promise, the response can be one of 'allowed' or 'denied' depending on whether the visitor allowed or denied access to the requested media device. The Error may have one of the following causes: INTERNAL_ERROR.