authic_app_sdk 1.0.0+2 copy "authic_app_sdk: ^1.0.0+2" to clipboard
authic_app_sdk: ^1.0.0+2 copied to clipboard

Official SDK to integrate Authic's perks platform.

authic_app_sdk #

Official Authic SDK for Flutter applications.

Getting Started #

Android Configruation:

No Change required, works out of the box.

iOS Configuration: Add the following to your Info.plist file

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>

Usage #

You can use this SDK in two ways:

1. Initilize the SDK #

You should initilize the SDK with your tenantId and environment before using any other methods. We recommend you to initilize the SDK in the main.dart file.

import 'package:authic_app_sdk/authic_app_sdk.dart';

// Initialize the SDK
final _authicAppSdkPlugin = AuthicAppSdk(
  tenantId: "<your-tenant-id>", // Contact us to obtain your tenantId
  environment: Environment.sandbox,
);

2. Authenticate the user #

You can authenticate the user by calling the authenticate method. Call this method as soon as the user logs in to your app.

// Authenticate the user
_authicAppSdkPlugin.authenticate(email: "example@gmail.com");

Or, you can also send refferal code while signing up a user to your app


_authicAppSdkPlugin.authenticate(email: "example@gmail.com", referralCode: "REFERRAL_CODE");

3. Implementation #

3.1 Render UI elements #

We provide two UI elements.

3.1.1 Points Label #

You can use this widget to show the points of the user in your app.

AuthicPoints(
    sdk: _authicAppSdkPlugin,
)

If you have not authenticated the user, it will show a loading indicator. Once the user is authenticated, it will show the points of the user. It will update the points in real-time as you complete the quest.

3.1.2 Quests List #

You can use this widget to show the list of quests in your app.

AuthicQuests(
    sdk: _authicAppSdkPlugin,
)

If you have not authenticated the user, it will show a loading indicator. Once the user is authenticated, it will show the list of quests. Users can complete the quests and earn points. Everything is handled by the SDK.

3.2 Custom Implementation #

Our SDK provides a lot of methods to interact with the Authic platform. You can use these methods to build your custom UI elements.

We have the following methods exposed.

  1. To get the membership details of the user, including the total points the user has collected
_authicAppSdkPlugin.getMemberships();
  1. To get the list of quests available for the user
_authicAppSdkPlugin.getQuests(
    placeGroupUuid: "<uuid>", // Comes from membership.placeGroup.uuid
);
  1. To get the referral code of the user
_authicAppSdkPlugin.getReferralCode(
    membershipId: 0, // Comes from membership.id
    placeQuestId: 0, // Comes from quest.id of type REFERRAL_CODE
);
  1. To complete a quest, calling this function will handle everything and even update the points on the UI
_authicAppSdkPlugin.doQuest(
    context: context,
    quest: AuthicQuest(), // Send any Quest from quests list
);
  1. To logout the user, this will clear the user session and you will have to call the authenticate method again to authenticate the user
_authicAppSdkPlugin.logout();