How to handle tasks when the Vision Pro is taken off?

I have a grpc server running inside of a task. When the user takes the headset off, the grpc server will no longer work when they put the headset back on.

I would like to have this action detected so that I can cancel the task (which will effectively close the grpc server).

I am also using a visual indicator to let the user know if the server is running, but it will not accurately reflect the state of the server when removing and putting back on the headset.

Hello  @ericD_TRI  , thank you for your question!

Have you investigated ScenePhase at all? This may have the functionality you need, however instead of detecting when the user removes their Apple Vision Pro, it will detect when an app is placed into the background. This will happen when the app is no longer visible to the user, which includes removing the AVP.

If ScenePhase does not have the functionality you need, you can file an enhancement request using Feedback Assistant, and provide as much detail about your use-case as you can!

How to handle tasks when the Vision Pro is taken off?
 
 
Q