Return to app from browser

Hi ,

Currently in my Xamairn.Android I have 2 activities Mainactivity and SignoutActivity.
In my Mainactivity I have a button where when user clicks the button it goes to SignoutActivity.
Here I have implemented the signout codes of Auth0.
Here are the codes-

MainAcitivity-

this.Signout.Click += delegate
        {
             using (var intent = new Intent(this, typeof(SignOutActivity)))
                {
                    this.StartActivity(intent);
                }
        };

SignOutAcitivity-

  protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        this.LogoutAsync();
        Finish();
        
    }
public async Task<BrowserResult> LogoutAsync()
    {
        var clientOptions = new Auth0.OidcClient.Auth0ClientOptions
        {
            Domain ="",
            ClientId = "",
            Scope = "openid email offline_access",
            Browser = new PlatformWebView()
        };
        var logoutUrl = "Signout URl";
        string redirectUri = "I have proper callback uri";
 
        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        dictionary.Add("client_id", "random1234");
        dictionary.Add("returnTo", clientOptions.RedirectUri);

        string endSessionUrl = new RequestUrl(logoutUrl).Create(dictionary);

        var logoutRequest = new LogoutRequest();
        BrowserResult browserResult = null;

        browserResult = await clientOptions.Browser.InvokeAsync(new BrowserOptions(endSessionUrl, redirectUri)
        {
            Timeout = TimeSpan.FromSeconds((double)logoutRequest.BrowserTimeout),
            DisplayMode = logoutRequest.BrowserDisplayMode
        });
       
        return browserResult;
    }

Platformview-

class PlatformWebView : IBrowser
{
    public Task<BrowserResult> InvokeAsync(BrowserOptions options)
    {
        if (string.IsNullOrWhiteSpace(options.StartUrl))
        {
            throw new ArgumentException("Missing StartUrl", nameof(options));
        }

        if (string.IsNullOrWhiteSpace(options.EndUrl))
        {
            throw new ArgumentException("Missing EndUrl", nameof(options));
        }
        var tcs = new TaskCompletionSource<BrowserResult>();

        void Callback(string response)
        {
            ActivityMediator.Instance.ActivityMessageReceived -= Callback;

            // set result
            if (response == "UserCancel")
            {
                tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.UserCancel });
            }
            else
            {
                tcs.SetResult(new BrowserResult
                {
                    Response = response,
                    ResultType = BrowserResultType.Success
                });
            }
        }
        ActivityMediator.Instance.ActivityMessageReceived += Callback;
        var uri = Android.Net.Uri.Parse(options.StartUrl);
        var intent = new Intent(Intent.ActionView, uri);
        intent.AddFlags(ActivityFlags.NoHistory)
            .AddFlags(ActivityFlags.NewTask);
        Application.Context.StartActivity(intent);
        return tcs.Task;
    }
}

}

Problem is browser never returns to app,Also I have put a debugger at return browserResult,this debugger also does not hit.Please help me.

Hey there @tonyyyrocks39!

I don’t have Xamarin experience but in the meantime waiting for someone from community to help I would go to appropriate GitHub repo and raise an issue so that you may potentially get a quicker response from repo maintainer.

Hi,

Thanks for reply,I already created an issue here-

but still need help from the community

1 Like

Thank you I’ll try to research it myself as well. Will let you know if I find something!

I would try to reproduce the issue. Can you tell me what parts of our stack (quickstarts / docs / etc.) have you used for building that?

I have used 2 acitivity classes Mainactivity and signoutacitivity.In mainactivity ,itsjust have a logout button where after clicking it it navigates to signoutacitivity.In signoutacitivity it opens a url.Rest platformview and Activitymediator class i ahve taken it from here-

Hi ,

did you get any clue

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?