B4i Library User Authentication with Apple ID

Erel

Administrator
Staff member
Licensed User


Starting from iOS 13 there is integral support for letting the user sign in with the user Apple ID.

The AppleAuthButton is a custom view that manages authentication.

You need to add the AuthResult event which will be raised when the user successfully signs in:
B4X:
Sub AppleAuthButton1_AuthResult (Name As String, Email As String)
    Msgbox($"Name: ${Name}
Email: ${Email}"$, "")   
End Sub
Configuration:
1. Enable 'Apple Sign In' in the app identifier page in Apple developer console. The app id must be a non-wildcard id.
2. Download an updated provision profile and set it with:
B4X:
#ProvisionFile: xxx.mobileprovision
3. Add to main module:
B4X:
#AdditionalLib: AuthenticationServices.framework
#MinVersion: 13
#Entitlement: <key>com.apple.developer.applesignin</key><array><string>Default</string></array>
4. Add the class to your project and add the custom view.

Depends on: iXUI library.

Notes

The user will only be able to authenticate succeffully once. The username and email are empty if the user tries to sign in again.
This means that you must save the username and email and don't let the user sign in again.
During development you can reset it in the settings app:

Settings > Apple Id > Password & Security > Apple ID logins > {YOUR APP} > Stop using Apple ID
 

Attachments

Top