短いリファラーリンクの作成
注:この機能はSDKバージョン12.1.1+で利用可能です。ショートリンクは一度作成すると30日間有効です。
ショートリンクを使用すると、長くてパラメータがいっぱいのシンギュラーリンクを、共有に便利な短くて安全なリンクに変換できます。
通常、ショートリンクを動的に作成して、アプリのユーザーが友達と共有してアプリの使用を招待できるようにします。
ショートリンクを作成するには
- アプリのダウンロードにつながるシンギュラーリンク(シンギュラーリンクのFAQを参照)。
- リンクに動的に追加したいパラメータ(オプションの一覧はトラッキングリンクパラメータをご覧ください)。
- アプリの新規インストールを、リンクを共有したユーザーにさかのぼって追跡できるようにしたい場合は、参照元ユーザーの名前とID。
createReferrerShortLinkメソッドを使用して、以下の例のように短いリンクを作成します。
// Create a JSON object to add parameters to the Singular Link (if they don't exist in the link URL yet)
JSONObject params = new JSONObject();
try {
params.put("channel","sms");
params.put("another parameter","parameter value");
} catch (JSONException e) {
e.printStackTrace();
}
Singular.createReferrerShortLink (
"https://sample.sng.link/D52wc/cuvk?pcn=test", // The original Singular Link URL
"Referrer Name",
"Referrer ID",
params,
new ShortLinkHandler() {
@Override
public void onSuccess(final String shortLinkURL) {
view.post(new Runnable() {
@Override
public void run() {
// Add your share logic here
}
});
}
@Override
public void onError(final String error) {
view.post(new Runnable() {
@Override
public void run() {
// Logic to retry/abort/modify the params passed to
// the function, based on the cause of the error
}
});
}
});
// Create a JSON object to add parameters to the Singular Link (if they don't exist in the link URL yet)
val params = JSONObject()
try {
params.put("channel", "sms")
params.put("another parameter", "parameter value")
} catch (e: JSONException) {
e.printStackTrace()
}
Singular.createReferrerShortLink(
"https://sample.sng.link/D52wc/cuvk?pcn=test", // The original Singular Link URL
"Referrer Name",
"Referrer ID",
params,
object : ShortLinkHandler {
override fun onSuccess(shortLinkURL: String) {
view.post(Runnable {
// Add your share logic here
})
}
override fun onError(error: String) {
view.post(Runnable {
// Logic to retry/abort/modify the params passed to
// the function, based on the cause of the error
})
}
})