3. FID Authentication

3.1 FTSDKAuthDelegate

Before using Authentication functions, please make sure you have implemented FTSDKAuthDelegate

// MARK: FTSDKAuthDelegate

- (void)didSignInSuccess:(FTSDKSignIn *)signIn didSignInFor:(FTSDKUser *)user withMethod:(NSString *)authType {
    // Call when user successful login, and every time user open app again
}

- (void)didSignInFail:(FTSDKSignIn *)signIn with:(FTSDKError *)error {
    // Call when user login failed
}

- (void)didSignUpSuccess:(FTSDKSignIn *)signIn didSignInFor:(FTSDKUser *)user withMethod:(NSString *)authType {
    // Call when user successful signup
}

- (void)didSignUpFail:(FTSDKSignIn *)signIn with:(FTSDKError *)error {
    // Call when user signup failed
}

- (void)onFTSDKIsReady {
    // Call when FID is ready, make sure you have wait before use any FID's functions
    
    // Example:
    // Verify Pending Transacions
    // Setup player info before make purchase
}

- (void)onFTSDKErrorWithError:(FTSDKError *)error {
    // Call if FID init error
    // You need to block the user to continue using app/game
}

- (void)onFIDMaintenanceWithConfig:(MaintenanceConfigs *)config {
    // Call if FID is on maintenance mode
    // You need to show an Maintenance dialog
    // A refresh button can be reload your app/game
}

- (void)onFIDLinkAccountSuggestionWithMessage:(NSString *)message {
    // If user using 3rd login (Apple, Google, Facebook), we need suggess user link their account with phone number
    // You need to show an dialog to suggess user link account
    // A button Link Account will call [[FTSDKSignIn instance] linkAccount];
    // View Link Account feature before implement this
}

Asign delegate instance:

3.2 Sign In & Sign Up

Sign In/ Sign Up dialog

After implement FTSDKAuthDelegate, you can start call Sign In or Sign Up

To show Sign In & Sign Up dialog, call:

Multiple authentication methods provided by FID:

Change Product Name when login with Google & Facebook

When you use login with Google/Facebook, you will see "XXX" want to use facebook.com to....

If you want to change the text "XXX", please go to Build Setting, search "product name" then change the value to anything that you want.

And remember to add config to your Info.plist

Setup login with Facebook

You will need Facebook App ID and Facebook Client ID Token (We will give you)

Add new configs to your Info.plist

  • FacebookAppID

  • FacebookClientToken

  • FacebookUrlSchemeSuffix (optional)

Go to your Target -> Info and add new URL Types:

  • fbxxx (xxx is FacebookAppID)

Setup login with Google

You will need GoogleService-Info.plist file (We well give you)

Drag file to your project, remember check Copy If Need option and choose Target

Go to your Target -> Info and add new URL Types:

  • com.googleusercontent.apps.xxx-yyy (You can find it in GoogleService-Info.plist file)

Setup login with Apple

By default, when we give you certificate and profile, it will include InApp-Purchage and SignIn with Apple capability

You need add some Capability to enable functions:

  • In-App Purchase

  • Sign in with Apple

You will need setup some Associated Domain and deeplink, we will give you

3.3 Forgot Password

When user use Phone Number and Password, if forgot, they can change password by SMS OTP, just click ForgotPassword on Sign In & Sign Up dialog

If a user is using a third-party login such as Apple, Google, Facebook, or PlayNow, we suggest linking their account with a phone number.

Before call link account, you need implement FTSDKLinkAccountDelegate first:

Asign delegate instance:

Start link account:

3.5 Sign Out

Call Sign Out with callback:

3.6 Refresh Token

FID employs JWT for authorization, whereby the accessToken has a shorter lifespan than the refreshToken.

Additionally, FID automatically calls for a refresh token each time the user accesses the app/game and automatically retries when the accessToken has expired.

However, when utilizing FID's accessToken, it is crucial to take into account its lifespan.

It is advisable to attempt a refresh token call before requesting APIs with FID's accessToken to ensure that it has not expired.

3.7 Get User Information

Following a successful login, you can obtain user information at any point by simply making a call to:

3.8 Change User Password

Following a successful login, you can allow user change their password by simply making a call to:

3.9 Auto Login

By default, FID will request auto login everytime user open app, but if you want to disable auto login, you can use setting when config SDK:

Then, you can manual check SDK is authorized with:

Last updated