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.
Enable Firebase Dynamic Links for your Firebase project in the Firebase console. Then, include the Dynamic Links SDK in your app. You can create Dynamic Links programmatically or by using the Firebase console. When your app opens, use the Dynamic Links SDK to check if a Dynamic Link was passed to it.
Dynamic Links are smart URLs that allow you to send existing and potential users to any location within your iOS or Android app. They survive the app install process, so even new users see the content they're looking for when they open the app for the first time. Dynamic Links are no-cost forever, for any scale.
You need to have an existing flutter project or create a new flutter project using flutter create <Your Project Name> command. Then there is a plugin called “firebase_dynamic_links” and add it to your created project's pubspec. yaml file. This plugin will help to detect firebase dynamic links in our application.
The created short Dynamic Link will not expire. Repeated calls with the same long Dynamic Link or Dynamic Link information will produce the same short Dynamic Link. The Dynamic Link domain in the request must be owned by requester's Firebase project.
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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With