question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using backwards compatible iOS SafariViewController for Xamarin.Forms

See original GitHub issue

I have looked at the Xamarin.Forms sample and it seems unclear to me how I would use (or reference) the iOSClient implementation of SFSafariViewController instead of SFAuthenticationSession with the IBrowser interface. Is it possible to accomplish this with OidcClient2?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mleechcommented, Apr 27, 2018

Here’s a (fairly hacky) sample implementation of a pre-iOS 11 IBrowser implementation

public class SafariBrowser : IBrowser
{
    public Task<BrowserResult> InvokeAsync(BrowserOptions options)
    {
        var task = new TaskCompletionSource<BrowserResult>();

        var safari = new SFSafariViewController (new NSUrl (options.StartUrl));

        AppDelegate.CallbackHandler = async url =>
        {
            await safari.DismissViewControllerAsync (true);
            task.SetResult(new BrowserResult()
            {
                Response = url
            });
        };

        // https://forums.xamarin.com/discussion/24689/how-to-acces-the-current-view-uiviewcontroller-from-an-external-service
        var window= UIApplication.SharedApplication.KeyWindow;
        var vc = window.RootViewController;
        while (vc.PresentedViewController != null)
        {
            vc = vc.PresentedViewController;
        }
        vc.PresentViewController (safari, true, null);

        return task.Task;
    }
}

see https://github.com/IdentityModel/IdentityModel.OidcClient.Samples/blob/master/iOSClient/iOSClient/AppDelegate.cs for the implementation and usage of the CallbackHandler property

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using backwards compatible iOS SafariViewController for ...
I have looked at the Xamarin.Forms sample and it seems unclear to me how I would use (or reference) the iOSClient implementation of ......
Read more >
Web Views in Xamarin.iOS
This document describes the various ways a Xamarin.iOS app can display web content. It discusses WKWebView, SFSafariViewController, Safari, ...
Read more >
Testing backwards compatibility of Xamarin Apps
Testing backwards compatibility of Xamarin Apps ; 1. Xamarin iOS app with device compatibility ; 2. Older OS versions and Xamarin.Forms ; 1....
Read more >
Xamarin iOS app rejected on appstore for using safari auth
Hi, we have implemented auth0 on a xamarin forms app following the example on github. Unfortunately the app got rejected on the iOS...
Read more >
Migrating from Xamarin Forms to .NET MAUI
Fortunately they are still supported in MAUI but only for backwards compatibility and you can register these in the MAUI App Builder. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found