짧은 리퍼러 링크 만들기
참고: 이 기능은 SDK 버전 12.1.1 이상에서 사용할 수 있습니다. 짧은 링크는 일단 생성되면 30일 동안 활성 상태로 유지됩니다.
짧은 링크를 사용하면 매개변수로 채워진 긴 Singular 링크를 공유하기에 편리한 더 짧고 안전한 링크로 변환할 수 있습니다.
일반적으로 앱 사용자가 친구와 공유하여 앱을 사용하도록 초대할 수 있도록 짧은 링크를 동적으로 생성하는 것이 좋습니다.
짧은 링크를 만들려면 다음이 필요합니다:
- 앱 다운로드로 연결되는 Singular 링크 ( Singular 링크 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
})
}
})