sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Identify when iOS app runs on VisionOS

Open philipphofmann opened this issue 1 year ago • 2 comments

Description

It's useful for users to know if their iOS app runs on VisionOS. As of April 4th, 2024, there is no official API for this yet; see Apple forum and Stackoverflow. Once Apple adds an official API similar to NSProcessInfo.iOSAppOnMac we can send this information on the device context.

This is related to https://github.com/getsentry/sentry-cocoa/issues/3825.

philipphofmann avatar Apr 04 '24 12:04 philipphofmann

related: https://medium.com/@timonus/low-hanging-fruit-for-ios-apps-running-on-visionos-08a85db0fb31

possible workaround: https://github.com/timonus/TJMixpanelLogger/blob/0952cf0ccc54c23d730e45069ec2b56c24ae8e31/TJMixpanelLogger.m#L142-L145

kahest avatar Jan 15 '25 13:01 kahest

From internal communication by @itaybre:

extension ProcessInfo {
  public var isiOSAppOnVisionOS: Bool {
    // `UIWindowSceneGeometryPreferencesVision` is only available
    // https://developer.apple.com/documentation/uikit/uiwindowscene/geometrypreferences/vision?language=objc
    return NSClassFromString("UIWindowSceneGeometryPreferencesVision") != nil
  }
}

Tested both on device and simulator.

philprime avatar Dec 01 '25 13:12 philprime