Some important notes to avoid bugs when implementing Sign In With Apple

Tram Ho

In the previous section, I have instructed you to implement the Sign In With Apple function in the iOS app, but to deploy the most quickly and accurately, there are a few important notes that need to be grasped before starting. hands on implementation.

Design has only Sign In button, no Sign Up in low iOS version

Usually, applications that implement this function are mostly maintain, which means adding the Sign In With Apple button to the available sign in or sign up screen. This has been mentioned before, causing the design to be limited and we have to choose the best fit with the available design in harmony. However, there is a rather “annoying” point that developers will encounter if the application has a registry. That is: from iOS 13.0 to iOS 13.2, apple only supports the “Sign In With Apple” button without “Sign Up With Apple”. Only i0S 13.2 and up, we have “Sign Up With Apple” button. That means you must use the button titled “Sign In With Apple” for the purpose of Sign Up

How to fix:

Hence we have to accept using only 1 button for 2 functions, or create custom 1 new button.

Button cannot tap

This can be said to be a bug of this SDK, but the one that Apple provided is ASAuthorizationAppleIDButton (), which is actually a UIControl, however we can setTarget with .touchUpInside type for it to catch the event. But when running, it is not really smooth, sometimes long press to run (botay). In this case a lot of developers have encountered https://stackoverflow.com/questions/58114826/asauthorizationappleidbutton-not-responding-to-touchupinside-events

How to fix:

This problem can be fixed quite simply, by assigning UITapGestureRecognizer () to the button.

User information only returns 1 time

ASAuthorizationControllerDelegate () is used to get user information including email, full name, userIdentifier, …., via function

func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization)

These information will be used to post to the account creation server or login. However, it is true that when you click the sign in with apple button, the email and name information is only returned for the first time when the user uses this function, from the next time, only the userIdentifier will be returned. , the remaining fields will be nil. This can be a mechanism for security. Therefore mail information will need to be saved to the keychain (apple has instructions for this too).

How to fix:

This will make Dev testing a bit difficult, but if we understand the mechanism, it can be easily fixed: Apple will save the Bundle ID of the app, then if requested information then it will not pay. back from the next time. So we can delete the app used Sign In With Apple in the Settings of the iPhone

Apple’s Enterprise Account cannot generate a certificate containing Sign In With Apple

This is quite the annoyance that I have encountered, if in the project has been divided into staging or development environment, creating certificate with enterprise account, it will not be able to add the sign in with apple function. That must be created with an Apple Programing account to have. Pulling along a bunch of other config changes is very inconvenient

How to fix

You can definitely use a certificate to create a Sign In With apple capacity, but you can still trick it by using it on certificate production, and then configuring the API for the environment. staging or dev is fine

summary

Above are some of my “life” experiences when implementing this function, although not much, but very important for those who do not know. Wish you successful application!

Share the news now

Source : Viblo