Skip to content

Commit

Permalink
Merge pull request #11 from AyogoHealth/NFP-1073
Browse files Browse the repository at this point in the history
[iOS] Fix OAuth on iOS 13
  • Loading branch information
dpogue authored Jun 10, 2020
2 parents 5945807 + 723894b commit 61170a8
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/ios/OAuthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ class ASWebAuthenticationSessionOAuthSessionProvider : OAuthSessionProvider {
}

func start() {
#if swift(>=5.1)
if #available(iOS 13.0, *) {
if let provider = self.delegate as? ASWebAuthenticationPresentationContextProviding {
self.aswas.presentationContextProvider = provider
}
if #available(iOS 13.0, *) {
if let provider = self.delegate as? ASWebAuthenticationPresentationContextProviding {
self.aswas.presentationContextProvider = provider
}
#endif
}

self.aswas.start()
}
Expand Down Expand Up @@ -118,7 +116,7 @@ class SafariAppOAuthSessionProvider : OAuthSessionProvider {


@objc(CDVOAuthPlugin)
class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate, ASWebAuthenticationPresentationContextProviding {
var authSystem : OAuthSessionProvider?
var callbackScheme : String?
var logger : OSLog?
Expand Down Expand Up @@ -218,13 +216,9 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
self.authSystem?.cancel()
self.authSystem = nil
}
}

#if swift(>=5.1)
extension OAuthPlugin : ASWebAuthenticationPresentationContextProviding {
@available(iOS 13.0, *)
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return self.viewController.view.window ?? ASPresentationAnchor()
}
}
#endif

0 comments on commit 61170a8

Please sign in to comment.