Avoiding the iOS Alert Dialog to Achieve Single Sign-On in Native Applications

Overview

This article explains how to achieve Single Sign-On (SSO) in native iOS applications without triggering the system’s authentication alert dialog. This dialog appears when an application uses ASWebAuthenticationSession for web-based authentication, such as OAuth 2.0 or OpenID Connect, and does not specify an ephemeral session.

Applies To

  • iOS
  • Native Application
  • SSO

Cause

The iOS alert dialog appears due to Apple’s privacy policy regarding data sharing between an application and the system web browser. This behavior is triggered when an application uses ASWebAuthenticationSession without opting for an ephemeral session.

Solution

To achieve SSO and prevent the iOS alert dialog from appearing, use SFSafariViewController instead of ASWebAuthenticationSession. This method allows for shared authentication sessions without triggering the privacy alert. More information is available in the documentation for When to use SFSafariViewController.