AppsFlyer Invitation Link
- Optional. This feature is used to generate invitation links and obtain inviter and invitee information. It does not include sharing. For sharing, call other APIs in our SDK or implement sharing separately.
- The game client calls the AppsFlyer invitation link generation interface (section 1 below) so the inviter can generate an invitation link, then share it through social channels for invitees to download and open the game.
- The game client calls the AppsFlyer reward query interface (section 2 below) to check whether the current user opened the game through a link and whether that event was recorded in the backend.
- Example: (1) User A generates link
a1for campaignathrough the invitation link generation interface. User A providesa1to User B. After User B opens the game through linka1, the game calls the reward query interface. The reward query callback returnsisSuccess=true, indicating that A successfully invited B and the record was sent to the game server. (2) When User B opens the game through linka1again, the game calls the query interface and the reward query callback returnsisSuccess=false. (3) User A generates linkb1for campaignbthrough the invitation link generation interface. After User B opens the game throughb1, the game calls the reward query interface and the reward query callback returnsisSuccess=true.
AndroidManifest.xml Configuration
Configure the scheme for the launch activity as required, as shown below:
xml
<activity
android:name="com.gd.sdk.test.MainActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme={Enter the Scheme provided by us. The usual format is "gamecode (lowercase) + Facebook app ID"} />
</intent-filter>
</activity>Check gd_config.xml
Check whether the AppsFlyer Key and AppInviteOneLink ID in gd_config.xml exist and are the latest values
java
<!-- AppsFlyer Key -->
<string name="gd_appsflyer_key" translatable="false">{Provided in the SDK package: xxxxxxxxxxxxx}</string>
<!-- AppInviteOneLink ID -->
<string name="gd_app_invite_one_link_id" translatable="false">{Provided in the SDK package: xxxx}</string>1. Game Client Calls the AppsFlyer Invitation Link Generation Interface
Note: This can be called only after the game client has called the check server interface and the role interface.
Call method:
public static void gamedreamerInviteLink(Context context,
@NonNull String inviteEventKey,
@Nullable String inviteEventValue,
@NonNull String inviteChannel,
GamedreamerInviteLinkListener listener)Note: This can be called only after the game client has called the check server interface and the role interface.
Parameters
| Parameter | Description |
|---|---|
| context | Context object |
| inviteEventKey | Share event key (provided by product) |
| inviteEventValue | Pass-through value for the share event |
| inviteChannel | Share channel. Pass a com.gd.sdk.GDChannel value, such as GDChannel.NORMAL |
| listener | Generated invitation link callback |
Callback Parameter Description
java
onResult(boolean isSuccess, String link, String message)| Parameter | Description |
|---|---|
| isSuccess | Whether generation succeeded |
| link | The generated URL. After the client obtains the URL, it should use the inviteChannel passed during the call to launch the corresponding share channel by itself and let the user share this URL. |
| message | Interface call message |
Example Code
java
GDSDK.gamedreamerInviteLink(context, "hw_invite0915", "{\"inviteTime\":\"1601186935\",\"inviteTag\":\"default\",\"inviteAccountId\":82}", GDChannel.NORMAL, new GamedreamerInviteLinkListener() {
@Override
public void onResult(boolean isSuccess, String link, String message) {
handleAFLink(isSuccess, link, message);
}
});2. Game Client Calls the AppsFlyer Reward Query Interface
Note: This can be called only after the game client has called the check server interface and the role interface.
Call method:
public static void gamedreamerInvitationRewards(Context context, GamedreamerInvitationRewardsListener listener)Parameters
| Parameter | Description |
|---|---|
| context | Context object |
| listener | Query result callback |
Callback Parameter Description
java
onRewardResult(boolean isSuccess)| Parameter | Description |
|---|---|
| isSuccess | Whether the current player was invited and this call notified the server to issue the reward. |
Example Code
java
GDSDK.gamedreamerInvitationRewards(this, new GamedreamerInvitationRewardsListener() {
@Override
public void onRewardResult(boolean isSuccess) {
handleAFLinkReceive(isSuccess);
}
});