Azure Mobile Services LoginAsync hangs / freezes in iOS sub project of Xamarin Forms PCL solution

LuisMarquesLuisMarques GBMember, University ✭✭

Hi All, is anyone experiencing issues with calling the Azure Mobile Services LoginAsync?

This is happening currently when using the Google provider.

In this Xamarin Forms PCL solution I also have the Android and Windows Phone sub projects. Both successfully call LoginAsync and I'm able to continue to my app homepage. LoginAsync gets called from the PCL shared code using the Xamarin Forms dependency service, which means that ultimately it gets called at the platform specific level due to the platform specific implementation of LoginAsync.

The issue is that the LoginAsync never returns when it gets called from the iOS subproject and it doesn't even show the Google user / password page...
On Android and Windows Phone the LoginAsync successfully shows the login pages, and authenticates the user.

If anyone has found this issue and worked around it then please let me know how you fixed it. The weird thing is - it doesn't even throw an exception!!
I believe I had this working previously before I upgraded to the latest version of Xamarin Forms with the new App Class. Could this be just a coincidence?

Any help would be greatly appreciated.

Posts

  • LuisMarquesLuisMarques GBMember, University ✭✭

    Hi, I have been thinking about this and it just occurred to me today that the reason the iOS sub project is not getting a "call back" is because I gave Loginasync a new view controller instead of the one currently controlling/showing my "choose login provider page". So in other words, the google user / password prompt page is being "sent" to the new hidden view controller, not the active visible one. The reason I think this might be the issue is because with the new App class we are not meant to create the window and view controller objects - we just call a new load page method which hides all this complexity from us. This is fine but it left me with a problem - how do I get access to the active view controller on this xamarin forms sub project? To be clear - I'm trying to access the view controller on the iOS platform specific project. The only thing I could find was to call a method on the app object to get the main page and then called create view controller from that main page. This lets me call Loginasync passing this new view controller and the google provider params but I might be feeding it the wrong one... Anyway, this is just an unproven theory as I don't know how create view controller works - it might return the active view controller if one already exists associated with the current view as opposed to creating a new one to wrap the same page. I hope all that made sense!!

    I'll post a generic question on xamarin forms forum about how to get access to the view controller using the latest forms load page method etc..

  • LuisMarquesLuisMarques GBMember, University ✭✭

    fixed the issue - it was the view controller as I suspected.

  • KernShenEngKernShenEng SGUniversity

    Hi LuisMarques, I stuck with this too. May I know how you resolve it?

  • jamesqquickjamesqquick USUniversity

    @LuisMarques how did you end up getting the correct ViewController to pass into the call?

  • jamesqquickjamesqquick USUniversity

    Finally found out how to get the correct view reference. Snippet below.

    var view = UIApplication.SharedApplication.KeyWindow.RootViewController;
    await App.MobileService.LoginAsync(view, provider);

  • AlejandroSeguraAlejandroSegura USMember ✭✭

    Was there anything else anyone did on this to get it working? I did the same as OP but the App just sits there nothing happens?

    This is the last code ran:
    var user = await client.LoginAsync(controller,
    MobileServiceAuthenticationProvider.Google);

    controller is the UIViewController acquired via UIApplication.SharedApplication.KeyWindow.RootViewController;

    This is in iOS PCL.

Sign In or Register to comment.