Mohamed Al Sabbagh
Mohamed Al Sabbagh

Reputation: 91

Navigating from xamarin multi-platform page to iOS or android page

I'm trying to follow this tutorial on creating a login page using Auth0: https://auth0.com/docs/quickstart/native/xamarin/01-login#handing-the-callback-url and noticed that the tutorial creates two separate login pages for android and iOS, as if they are two separate apps/projects/solutions. But my app is supposed to be compatible with both android and iOS, so I created a forms page under RoseySports.ios called Login_iOS (As indicated in screenshot 1) and would like to test it out to see if the login page works, but cannot seem to find a way to set the MainPage as Login_iOS (screenshot 2). I would like for it to be so that if a device is running iOS, it will redirect the user to the iOS version of the login page, and vice versa for android. Sorry if I'm not using the correct terminology when describing my issue. The reason I had to create two separate login pages for iOS and android was because i had to use using Auth0.OidcClient; as there are separate Nuget packages for the iOS solution and Android solution, which doesn't work when trying to put it on the main project (the one compatible for both iOS and Android).

And please let me know if there's a way to make just one login page for both platforms using Auth0.

Screenshot 1 Screenshot 2

UPDATE:

This is what I've done now, but I'm getting an error at MainPage = new RoseySports.Login_iOS(); saying that Login.iOS does not exist in the namespace RoseySports. This is the rest of the code:

        `switch(Device.RuntimePlatform)
        {
            case Device.iOS:

                MainPage = new RoseySports.Login_iOS();

                    break;

            case Device.Android:

                MainPage = new Login_Page();

                break;
        }`

Upvotes: 1

Views: 277

Answers (1)

Ivan I
Ivan I

Reputation: 9990

You have multiple questions and in StackOverflow you should not ask them in one question, but let's try to address them:

  • Pages are only graphic elements and there is no need to implement separate graphic elements in iOS and Android in most cases, and yours doesn't look like a valid one for that
  • In general you can implement some code as platform specific. If you are using shared projects you can use conditional compiling, if not then dependency injection
  • You can use some of the technics above to do what you wanted to do (have different versions of pages per platform)

Upvotes: 1

Related Questions