Skip to content

GameKit UnsupportedOperationForOSVersion Exception thrown on iOS 18 #67

Closed

Description

@BennyFranco

On iOS 18 (and probably since iOS 15 that is the minimum indicated in the documentation), the plugin is throwing the following exception:

GameKitException: Code=-7 Domain=GKErrorDomain Description=No se pudo completar la operación. 
(Error de GKErrorDomain -7) (UnsupportedOperationForOSVersion) at 
Apple.GameKit.DefaultNSErrorHandler.ThrowNSError (System.IntPtr nsErrorPtr) [0x00000] in 
<00000000000000000000000000000000>:0 Rethrow as TypeInitializationException: 
The type initializer for 'Apple.GameKit.GKGameActivity' threw an exception.

I found that is happening because the current implementation of GKGameActivity has a static constructor calling a native function that registers a delegate that needs iOS 26 as minimum:

static GKGameActivity()
{
Interop.GKGameActivity_SetWantsToPlayCallback(OnWantsToPlay);
}

On C# static constructors are called at least once independently from the user, it should be used to initialize static data or actions that need to be performed only once, however static GKGameActivity() is calling a native function in Swift that is not available on iOS 18:

@_cdecl("GKGameActivity_SetWantsToPlayCallback")
public func GKGameActivity_SetWantsToPlayCallback(callback : @escaping WantsToPlayActivityCallback) {
if #available(iOS 26.0, macOS 26.0, tvOS 26.0, visionOS 26.0, *) {
_localPlayerListener.WantsToPlayActivity = callback;
} else {
DefaultNSErrorHandler.throwApiUnavailableError();

I think the delegate registration must be Developer's responsibility if he needs to use this class and it should be his responsibility to handle the exception, I don't think it is good to have an exception on initialization.

As a suggestion, perhaps it will be better to have a non-static public constructor that the developer can call explicitly.

Activity

  1. michaelclockstone commented on Dec 17, 2025

    @michaelclockstone

    This bug completely prevents user authentication on older devices. As a workaround for development you can make Unity Development builds. For some reason authentication then works.

  2. ryzngard commented on Dec 25, 2025

    @ryzngard
    Collaborator

    This should be fixed by #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions