Haptic Feedback for Instant Games

Instant Games now support haptic feedback. This feature is supported on Android and iOS devices that have an integrated vibrator. The feedback produced by iOS devices slightly differs from that of Android devices.

Android

  • The intensity of the vibration is set to the default value of the device: VibrationEffect.DEFAULT_AMPLITUDE.
  • The duration of the vibration is set to 200 milliseconds.

iOS

  • The intensity and duration of the vibration is provided by UIImpactFeedbackGenerator, initialized with a style of UIImpactFeedbackStyleHeavy.

In other words, Android’s feedback lasts a split second longer than that of iOS and tends to be slightly more noticeable.

API Documentation

performHapticFeedbackAsync()

Requests the user's device to perform a haptic feedback (making the device vibrate). This API call will only work on devices with an integrated vibrator. This feature is now available on Instant Games for Android and iOS.

Examples

FBInstant.performHapticFeedbackAsync()
  .then(function() {
    ...
});
  • Throws CLIENT_UNSUPPORTED_OPERATION
  • Throws INVALID_OPERATION

Returns Promise A promise that resolves when the haptic feedback call has been correctly requested.

See Also