Search code examples
iossettingsimessage

iOS: Raise to Listen


When receiving a voice memo in iMessage, you can lift the phone to listen to the voice memo through the top speaker (condition: the option is enabled in the settings).

Is it possible that this works with other apps? I've searched the web for it, but there doesn't seem to be a resource on the subject.


Solution

  • The UIResponder class has methods to detect motion, although they're usually used to detect a shake with the UIEventSubtypeMotionShake motion constant.

    There may be one for detecting when the device is raised, but I can't find one in Apple's documentation so it's probably private (if indeed it exists).

    You could try playing around with different values but to bear in mind that if you find one that works and is not referenced in Apple's documentation, it could be subject to change in future versions of iOS.

    Alternatively you could use the CoreMotion framework directly. Take a look at this StackOverflow article for an example of how to use it.