Adjust 的短链接解决方案能将复杂的长链接变成简洁的短链接。短链接会保留深度链接和推广活动信息,如果用户尚未安装您的应用,则会将用户转到应用商店。
使用本节中描述的方法来解析您的短链接。
在 Adjust SDK 中设置深度链接
在 Adjust SDK 中添加对以下内容的支持:
设置 Adjust SDK 来解析短链接
public static void processDeeplink(Uri url, Context context, OnDeeplinkResolvedListener callback)
Adjust SDK 会使用 onCreate
或 onNewIntent
方法,传递活动 intent 对象中的深度连接信息。深度链接位于intent
对象的data
属性。应用启动,且上述方法之一被调用后,您就可以读取深度链接内容了。调用processDeeplink
方法来解析将用户深度链接至应用的 Adjust 短链接 URL 。
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)
val intent = intent val webpageURL = intent.data Adjust.processDeeplink(webpageURL, this) { resolvedLink -> // resolvedLink contains either resolved URL (if it was unshortened) // or just echoed URL if it was not shortened Log.d("Example", resolvedLink) }}
@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Intent intent = getIntent(); Uri webpageURL = intent.getData(); Adjust.processDeeplink(webpageURL, this, new OnDeeplinkResolvedListener() { @Override public void onDeeplinkResolved(String resolvedLink) { // resolvedLink contains either resolved URL (if it was unshortened) // or just echoed URL if it was not shortened Log.d("Example", resolvedLink); } });}
override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent)
val webpageURL = intent.data Adjust.processDeeplink(webpageURL, this) { resolvedLink -> // resolvedLink contains either resolved URL (if it was unshortened) // or just echoed URL if it was not shortened Log.d("Example", resolvedLink) }}
@Overrideprotected void onNewIntent(Intent intent) { super.onNewIntent(intent);
Uri webpageURL = intent.getData(); Adjust.processDeeplink(webpageURL, this, new OnDeeplinkResolvedListener() { @Override public void onDeeplinkResolved(String resolvedLink) { // resolvedLink contains either resolved URL (if it was unshortened) // or just echoed URL if it was not shortened Log.d("Example", resolvedLink); } });}
如果您发送至processDeeplink
方法的链接为短链接,那么resolvedLink
就会返回延长后的原始链接。如果您传递给该方法的链接未被缩短,那么resolvedLink
包含的链接与您传递的链接相同。