Unhandled promise rejection: Exception occurred while executing exported mothod startObserving on module ExponentGyroscope: Subscription has been released, cannot call methods on a released subscription

Hello,

I’m fairly new to react native and expo. I’m trying to implement a Gyroscope in my application but am encountering two problems.

  1. I followed the expo Gyroscope documentation, but my subscription state stays null and the listener is never unsubscribed.

afbeelding

I fixed this by now calling Gyroscope.removeAllListeners() in the _unsubscribe() method, but that’s not what the documentation suggests.

  1. This problem breaks my gyroscope and I can’t wrap my head around what is happening. I have a headless JS function running, along with a service to periodically update a value. I largely followed this medium post: How to create an unstoppable service in React Native using Headless JS | by Mathias Silva | React Brasil | Medium . When I now close the app and reopen, I receive the following error and my Gyroscope listener does not register any updates anymore:

Possible Unhandled Promise Rejection (id: 12):
Error: Encountered an exception while calling native method: Exception occurred while executing exported method setUpdateInterval on module ExponentGyroscope: Subscription has been released, cannot call methods on a released subscription.
Error: Encountered an exception while calling native method: Exception occurred while executing exported method setUpdateInterval on module ExponentGyroscope: Subscription has been released, cannot call methods on a released subscription.

I have been trying but cannot find a solution to this problem.
Any help is appreciated!

Kind regards