Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Custom URL Scheme

$
0
0

Hi,

I would like to create a custom URL scheme, but I've stumbled upon some problems.

The url scheme "example://key/secretkey" fires the below LoginActivity:

[Activity(Label = "Sifo.PanelApp", MainLauncher = true)]
public class MainActivity : AndroidActivity
{

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        Xamarin.Forms.Forms.Init(this, bundle);
        SetPage(Sifo.PanelApp.Shared.SifoPanelApp.RootPage);
    }

}

[Activity(Label = "Url Scheme Log in", MainLauncher = true)]
[IntentFilter(new[] { Intent.ActionView }, DataScheme = "example", DataHost = "key", Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault })]
public class LoginActivity : AndroidActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Get the "secretkey" from the url scheme and store it
        DomainModel.UserService.LoginId = Intent.Data.LastPathSegment;

        Xamarin.Forms.Forms.Init(this, bundle);
        SetPage(Sifo.PanelApp.Shared.SifoPanelApp.RootPage);
    }
}

But unfortunately you receive an exception if you execute SetPage twice.
So how should I go about this? I would like to get the info from the URL scheme and resume the App.


Viewing all articles
Browse latest Browse all 58056

Trending Articles