Skip to content

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 a1 for campaign a through the invitation link generation interface. User A provides a1 to User B. After User B opens the game through link a1, the game calls the reward query interface. The reward query callback returns isSuccess=true, indicating that A successfully invited B and the record was sent to the game server. (2) When User B opens the game through link a1 again, the game calls the query interface and the reward query callback returns isSuccess=false. (3) User A generates link b1 for campaign b through the invitation link generation interface. After User B opens the game through b1, the game calls the reward query interface and the reward query callback returns isSuccess=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>

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 ​

ParameterDescription
contextContext object
inviteEventKeyShare event key (provided by product)
inviteEventValuePass-through value for the share event
inviteChannelShare channel. Pass a com.gd.sdk.GDChannel value, such as GDChannel.NORMAL
listenerGenerated invitation link callback

Callback Parameter Description ​

java
onResult(boolean isSuccess, String link, String message)
ParameterDescription
isSuccessWhether generation succeeded
linkThe 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.
messageInterface 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 ​

ParameterDescription
contextContext object
listenerQuery result callback

Callback Parameter Description ​

java
onRewardResult(boolean isSuccess)
ParameterDescription
isSuccessWhether 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);
			}
		});