I have a dynamic Link set up where you can share the the link with people like this
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Join my group for Lesn");
intent.putExtra(Intent.EXTRA_TEXT, "https://y28rt.app.goo.gl/?link=https://Lesn.com/joinGroup&apn=c.kristofer.jax2[&amv=21]&groupUid=" + groupUid);
startActivity(intent);
As you can see in the link
" https://y28rt.app.goo.gl/?link=https://Lesn.com/joinGroup&apn=c.kristofer.jax2[&amv=21]&groupUid= " + groupUid
I put extra data which is
groupUid=" + groupUid)
My question is How do I receive that string from the link using this
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
Uri deeplink = null;
if (pendingDynamicLinkData != null){
deeplink = pendingDynamicLinkData.getLink();
}
}
});
Edit
So my problem was actually putting in the wrong value for my deeplink. Now I've got it to work but my other problem still persists. Using deeplink.getQueryParameter("groupUid") it returns a null when I try to log the value.
First of all, to get parameter from a deepLink, using Uri method
String group = deeplink.getQueryParameter("groupUid");
Before that, to attach a parameter to dynamic link of Firebase, you must add parameter to the main link before you generate dynamic link
private void attachParameter(String groupUid) {
Uri link = Uri.parse("https://Lesn.com/joinGroup")
.buildUpon()
.appendQueryParameter("groupUid", groupUid)
.build();
generateDynamicLink(link.toString());
}
private void generateDynamicLink(String link) {
Uri dynamicLink = Uri.parse("https://y28rt.app.goo.gl")
.buildUpon()
.appendQueryParameter("link", link)
.appendQueryParameter("apn", "c.kristofer.jax2")
.build();
Log.d(TAG, "generateDynamicLink: " + dynamicLink.toString());
}
However I recommend to use firebase lib instead of build dynamic link manual:
private void generateDynamicLinkWithLib(Uri link) {
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(link)
.setDynamicLinkDomain("y28rt.app.goo.gl")
.setAndroidParameters(new Builder().build())
.setIosParameters(new IosParameters.Builder("c.kristofer.jax2")
.build())
.buildDynamicLink();
Log.d(TAG, "generateDynamicLink: " + dynamicLink.getUri().toString());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.