openid / openid/AppAuth-iOS

Support UISceneDelegate

Open
#928 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement triage
Dominant language
Objective-C
Stars
2k
Forks
867
Avg merge
4d 48m
Merged PRs (30d)
1

Description

Apple will soon force the use of UISceneDelegate

func application(    _ app: UIApplication, open url: URL,options: [UIApplication.OpenURLOptionsKey: Any] = [:]
  ) -> Bool {  .... 

in Appdelegate will be replaced by

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {

in UISceneDelegate

which means RNAppAuthAuthorizationFlowManagerDelegate is used by UISceneDelegate rather than AppDelegate

apple suggest call like this in UISceneDelegate


  func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let urlContext = URLContexts.first else { return }
      let url = urlContext.url
      let options: [UIApplication.OpenURLOptionsKey: Any] = [
        .sourceApplication: urlContext.options.sourceApplication as Any,
        .annotation: urlContext.options.annotation as Any
      ]


    // 🔹 Resume AppAuth if in progress
    if let delegate = authorizationFlowManagerDelegate {
      _ = delegate.resumeExternalUserAgentFlow(with: url)
    
    }
    _ = RCTLinkingManager.application(UIApplication.shared, open: url, options: options)
  }
}

However , the OIDExternalUserAgentIOS is now stick to AppDelegate , so app will break

    id<UIApplicationDelegate, RNAppAuthAuthorizationFlowManager> appDelegate = (id<UIApplicationDelegate, RNAppAuthAuthorizationFlowManager>)[UIApplication sharedApplication].delegate;
    if (![[appDelegate class] conformsToProtocol:@protocol(RNAppAuthAuthorizationFlowManager)]) {
        [NSException raise:@"RNAppAuth Missing protocol conformance"
                    format:@"%@ does not conform to RNAppAuthAuthorizationFlowManager", appDelegate];
    }

i can overcome above by referencing delegate to AppDelegate by
var authorizationFlowManagerDelegate = SceneDelegate.current?.authorizationFlowManagerDelegate

But, the rootviewcontroller will move to UISceneDelegate as well , and app will still crash by NSAssert

 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
    NSAssert(presentingViewController != nil,
             @"presentingViewController cannot be nil on iOS 13");
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
    
    _presentingViewController = presentingViewController;
  } 

It would be nice if AppAuth-IOS can support UISceneDelegate so we dont need to find workaround or patch for it

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing OIDExternalUserAgentIOS and RNAppAuthAuthorizationFlowManagerDelegate, including the AppDelegate protocol lookup and presentingViewController assertion shown in the issue. Compare those paths with the UISceneDelegate URL handling example. Done means OAuth callback handling and presentation work without AppDelegate or root-view-controller workarounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c, swift
Domain
authentication, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.