xamarin/ios-samples

XamarinFormsAppleSignIn for iOS

richardgarnier opened this issue · 2 comments

Regarding the sample, I was wondering in the iOS 13 sample, what the following line was doing exactly? (AppleSignInServiceiOS:54)

var controller = new ASAuthorizationController(new[] { req });

controller.Delegate = authManager;
controller.PresentationContextProvider = authManager; // <-- this one

controller.PerformRequests();

PresentationContextProvider is an interface named IASAuthorizationControllerPresentationContextProviding that offers a single method UIWindow GetPresentationAnchor(ASAuthorizationController controller)

However running the sample, I am observing:

  • commenting the line does not change the behaviour
  • GetPresentationAnchor is never called

I then tried to make it so that the method actually gets called, by adding [Export("authorizationController:presentationAnchorForAuthorizationController:")], as it is usually the case when binding Objective-C to C#. However, doing so makes gives the following compilation error:

The registrar found a signature mismatch in the method 'MticChat.iOS.AppleAuthManager.GetPresentationAnchor' - the selector 'authorizationController:presentationAnchorForAuthorizationController:' indicates the method takes 2 parameters, while the managed method has 1 parameters.

To give some context, I was interested in this method because on my iPhone, editing the name on the apple sign in window leads the keyboard to hide the text field being edited. I was hoping to be able to give a different window to prevent that issue from happening.

My understanding is that it is required under some iOS versions, and it provides the "anchor point" of where Apple should display the sign in dialog.

I'm not sure under what circumstances Apple calls it, maybe they only use it on iPads, or when you aren't signed in, or when the moon is full. Under what circumstances Apple chooses to call it is up to them, it is documented as required. 🤷 That's why we added it to the sample.