3. SDK Features
Extend
Activity using SDK must be extend FragmentActivity
by Java
or AppcompatActivity
by Kotlin
public class MainActivity extends FragmentActivity {
...
}
Login
This function will initialize the default configuration for the SDK and call the login/register form automatically.
Upon successful login/registration the SDK returns a model containing the user's data as
result
in callbackonSuccess()
. Handling of successful login/registration hereWhen login / registration is not successful, it will be handled at the callback
onFail()
FID.INSTANCE.login(new FIDCallBack<FIDUser>() {
@Override
public void onFail(@Nullable String error) {
}
@Override
public void onSuccess(FIDUser result) {
}
@Override
public void onCancel() {
}
});
Logout
When successful logout will be processed in callback
onSuccess()
When the logout fails, it will be handled at the callback
onFail()
FID.INSTANCE.logout(new FIDCallBack<Boolean>() {
@Override
public void onCancel() {
}
@Override
public void onFail() {
}
@Override
public void onSuccess(Boolean result) {
}
});
Refresh token (manual)
FID.INSTANCE.refreshToken(new FIDCallBack<FIDAuthentication>() {
@Override
public void onCancel() {
}
@Override
public void onSuccess(FIDAuthentication result) {
}
@Override
public void onFail() {
}
});
Get user information
Call the function to Refresh token before call getCurrentAccount with the syntax
Then call the function to get user information with the syntax
FID.INSTANCE.getCurrentAccount(Context, new FIDUserCallBack() {
@Override
public void onSuccess(FIDUser result) {
}
@Override
public void onFail() {
}
@Override
public void onSuggestionLinkAccount() {
}
});
In app purchase
Before using payment, dev needs to call
setPlayerInfo
function. Where:server_name
is the identifier of the game server andcharacter_name
is the name of the game character.
FID.INSTANCE.sendLogSelectServer("server_id");
FID.INSTANCE.sendLogSelectCharacter("character_name");
FID.INSTANCE.setPlayerInfo();
The partner side uses the available UI
Function to get list of items:
FPay.INSTANCE.getListProduct(Context context, new FPay.FPayCallBack<List<ProductItem>>() {
@Override
public void onPending() {
}
@Override
public void onCancel() {
}
@Override
public void onSuccess(List<ProductItem> result) {
}
@Override
public void onFailure(@NonNull String error) {
}
});
Item purchase handler function, passing in the paymentWithoutUISDK function the productInfo object is taken from the list item list in getListProduct function.
private void purchaseItemWithoutUI(){
ProductItem productItem = new ProductItem();
productItem.setStorePackageID("eclazz.item1");
productItem.setGameCode("FSDK");
productItem.setIapPackageId(12);
productItem.setInGamePackageID("152217");
productItem.setDisplayAmount(23000);
productItem.setDisplayCurrency("VND");
FunzyIAPOrderInfo info = new FunzyIAPOrderInfo();
FunzyIAPOrderInfo.FunzyIAPExtraDataOrder order = (FunzyIAPOrderInfo.FunzyIAPExtraDataOrder) info.getExtraDataInfo();
if (order != null) {
order.setCooOrderId("" + System.currentTimeMillis());
}
info.setExtraDataInfo(order);
FPay.INSTANCE.purchaseItemWithoutUI(this, productItem, info, new FPay.FPayCallBack<String>() {
@Override
public void onPending() {
}
@Override
public void onFailure(@NonNull String error) {
}
@Override
public void onSuccess(@NonNull String transactionId) {
}
@Override
public void onCancel() {
}
});
}
The
onSuccess
callback returns a list of items as listProductItem. Dev takes this data to self build interface.When the item list cannot be obtained, the dev will process it in the
onFail
callback.Upon successful item purchase, it will be processed in the
onSuccess
callback. In this callback return 1 transaction code.In case of unsuccessful item purchase, it will be handled at the
onFailure
' callback.When purchasing items that the user cancels will be handled in the
onCancel
callback.
How does the payment flow work?
All payment methods share the same flow of operations as follows:

Game calls the payment interface from the SDK. The game will get the item list from the SDK or the SDK shows the item list for the game The SDK sends a payment request to the server. The server notifies the game server through an api payment callback, the game server processes the transaction to add money or in-game items and then tells the game to display the results in the game. At the same time, the server also receives information and returns it to the SDK. Sdk send packages to client game. The SDK still reports the results to the game through a delegate. The game that has received the results from the game server (which is the most accurate) does not need to use the information returned from this SDK anymore. It is used in special cases.
Q&A
This part the game will ask the SDK to open a webview form for users to create questions about the game, as well like refer to the issues that the community has answered before,...
Call the Q&A function with the syntax:
FID.INSTANCE.openQA(this);
Connect Account
Call the Connect account function with the syntax:
FID.INSTANCE.connectAccount(new FIDCallBack<FIDUser>() {
@Override
public void onCancel() {
FIDCallBack.super.onCancel();
}
@Override
public void onSuccess(FIDUser result) {
}
@Override
public void onFail() {
}
});
Tracking
Using this code for some events:
FID.INSTANCE.sendLogSelectServer("server_name");
FID.INSTANCE.sendLogSelectCharacter("character_name");
FID.INSTANCE.sendLogLevelUp("1");
FID.INSTANCE.sendLogTutorialCompleted();
For custom events:
FID.INSTANCE.sendLogTracking("event_name", "extra_data")
Language
FID support multiple language: Vietnamese & English
FID.INSTANCE.configLanguage(LANGUAGE.VIETNAMESE)
Bubble support Button
Bubble support is other layout support multiple function: IAP, news, connect account, ...
For show bubble support:
FID.INSTANCE.showSupportButton(context, viewRoot);
For hide bubble support:
FID.INSTANCE.hideSupportButton();
Deeplink
For automatic handle deeplink like openApp or Ads, onelink, use code like beblow:
FID.INSTANCE.handleDeepLink(intent, context);
Change Password
FID.INSTANCE.changePassword(new FIDCallBack<FIDUser>() {
@Override
public void onFail(@Nullable String error) {
}
@Override
public void onSuccess(FIDUser result) {
}
@Override
public void onCancel() {
FIDCallBack.super.onCancel();
}
});
Update phone
Using for user login by thirdparty then want to connect with FID phonenumber account
FID.INSTANCE.updatePhone(new FIDCallBack<FIDUser>() {
@Override
public void onFail(@Nullable String error) {
}
@Override
public void onSuccess(FIDUser result) {
}
@Override
public void onCancel() {
FIDCallBack.super.onCancel();
}
});
Handle Giftcode
Using this for event scan QRcode to get giftcode ingame.
FIDGiftCode
code
String
Giftcode ingame
content
String
Description giftcode event
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
handleGiftCode();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleGiftCode();
}
void handleGiftCode() {
FID.INSTANCE.onReceiveGiftCode(getIntent(), new FIDGiftCodeCallBack() {
@Override
public void onSuccess(@NonNull FIDGiftCode fidGiftCode) {
}
});
}
Playnow Account Not Linked
If App/Game require link account for play now account before make an In App Purchase, you can use this function:
FID.INSTANCE.isPlayNowAccountNotLinked()
Enable Debug Log
FID.INSTANCE.enableDebug(true)
Proguard
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
##---------------End: proguard configuration for Gson ----------
-optimizationpasses 5
-optimizations !code/simplification/arithmetic,!field/*,!class/merging*/
-allowaccessmodification
-repackageclasses ''
-verbose
-keep class **$$Parcelable { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
# To support Enum type of class members
-keep enum * { *; }
#Keep native
-keep public class * {
public <methods>;
}
-keep class ai.ftech.FTechLog** {
public<fields>;
public<methods>;
}
-keep class ai.ftech.fid.FID** {
public<fields>;
public<methods>;
}
-keep interface * { *; }
-keep public class ai.ftech.fid.FidConfig** {
*;
}
-keep class ai.ftech.fid.domain.model.dynamicconfig.AuthConfigRequest** {
}
-keep class ai.ftech.fpay.FPay** {
public<fields>;
public<methods>;
}
-keep class com.appsflyer.** { *; }
-keep class kotlin.jvm.internal.** { *; }
Last updated