Skip to content

iOS/macOS: distinct sign_in_unavailable error code when the sign-in UI won't present - #237

Open
pdurasie wants to merge 1 commit into
Abedalkareem:developfrom
pdurasie:feature/ios-sign-in-unavailable-error
Open

iOS/macOS: distinct sign_in_unavailable error code when the sign-in UI won't present#237
pdurasie wants to merge 1 commit into
Abedalkareem:developfrom
pdurasie:feature/ios-sign-in-unavailable-error

Conversation

@pdurasie

Copy link
Copy Markdown

Added a separate error code for iOS when the sign-in UI won't present, so that client apps can distinguish between "The user saw the modal and closed it without signing in" and "The modal didn't show".

As an example for what that's useful: In my app I have a button for the user to sign into Game Center / Google Play. The Game Center modal won't show when it's been closed once already or when Game Center is switched off in the settings. In that case, I show a dialog directing the user to navigate to the settings and activating Game Center there.

For Android it's not necessary, because from my tests, the sign in UI would show every time, no matter how many times it's been declined already.

…n't present

On iOS/macOS, once the authentication handler has been set and the player is
still not authenticated, GameKit will not present the sign-in UI again from the
app. The usual cause is that Game Center is turned off or restricted in the
device's Settings, or no account is signed in there — something the user can
only resolve in Settings, not by retrying in-app. (No sign-in sheet is
necessarily shown first: with Game Center disabled the initial `signIn` resolves
with an error and never presents UI; the next call lands in this branch.)

The plugin previously surfaced this as `failed_to_authenticate`, making it
indistinguishable from a normal failed/declined attempt that the user can retry.

Add a dedicated `sign_in_unavailable` PluginError and return it from that branch
so apps can tell "the user can retry" apart from "send the user to device
Settings" and route accordingly.

Android is untouched; the Dart interface is unchanged (this only refines the
error code string carried by the existing PlatformException).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@theLee3 theLee3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for the contribution @pdurasie

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants