【发布时间】:2017-07-07 10:35:45
【问题描述】:
我在 Firebase 控制台中创建了一个动态链接。它有一个简短的 url,可将用户定向到应用程序内的 Activity。
我在 iOS 中也做了同样的事情,使用代码:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool
{
if let incomingUrl = userActivity.webpageURL
{
print(incomingUrl) //Here I get the url that the user clicked on
}
}
当用户点击动态短链接时,我试图在 Android 中获得准确的输出。 目前,我有:
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null)
{
deepLink = pendingDynamicLinkData.getLink();
}
// Handle the deep link. For example, open the linked
// content, or apply promotional credit to the user's
// account.
// ...
// ...
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "getDynamicLink:onFailure", e);
}
});
在这里,我可以获取深层链接,我对在Android中获取短链接没有明确的想法。
谢谢。
【问题讨论】:
标签: android firebase firebase-dynamic-links