App Center | HockeyApp will be transitioning into App Center on Nov. 16, 2019.

Invoking Feedback UI with a shake gesture


One common gesture you may want to add to your app is to let users shake the device and provide them an easy way to contact you from anywhere in your app.

Our SDKs In-App Feedback feature provides a nice way to let your apps users get in touch with you and even send annotated screenshots. The following code will automatically create a screenshot when the device is shaken and will open the compose feedback message UI.


This guide assumes you are an already integrated the HockeySDK into your app.


Integrate the following code in your root view controller:

  • Swift
import HockeySDK

override func canBecomeFirstResponder() -> Bool {
  return true
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent?) {
  if motion == .MotionShake {
  • Objective-C
@import HockeySDK;

- (BOOL)canBecomeFirstResponder {
  return YES;

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
  if (motion == UIEventSubtypeMotionShake) {
    [[BITHockeyManager sharedHockeyManager].feedbackManager showFeedbackComposeView];


On Android there is no system API for detecting a shake gesture - but there is a plethora of third party libraries available. Here is an example using Seismic by square:

import android.hardware.SensorManager;

import com.squareup.seismic.ShakeDetector;


public class MainActivity extends Activity implements ShakeDetector.Listener {

    protected void onCreate(Bundle savedInstanceState) {

        SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        ShakeDetector detector = new ShakeDetector(this);

    public void hearShake() {

Automatically capturing a screenshot and adding it to the message composer is currently not available on Android.

Xamarin iOS

Add the following code to your BaseView.cs file:

  public override void MotionEnded(UIEventSubType motion, UIEvent event)
    if (motion == UIEventSubType.MotionShake)