share playstore app and referral code - android

How to share playstore link to share app along with referral code. Playstore link to the app will not allow appending custom parameters so can't set it as deeplink for firebase dynamic links as parameters cant be appended in the dynamic link or can I?Is there any other way such that link opens or installs app and invite code is automatically inserted in text view
Referred below link but didnt work
How can I share referral code on facebook,whatapp,instagram and other platforms in android

This is a bit tricky.
Solution 1: use external tool from Branch.io
What is the proper way to create user invite codes using Branch?
Solution 2: Manual (hacky)
Peter wants to share it to Max.
Peter sends invitation url to Max.
The Url is not a direct PlayStore Url, it links to a PHP file. This file saves, when opened the IP of the client and redirects to the PlayStore.
Max opens the url, his IP is stored and he downloads the App.
On the first Appstart, you make a request to your database. If the IP matches, you can redeem.
This is not a perfect solution and needs to be improved, but just to give you an idea of how it could be done.

Here it is some code I have used with Firebase Dynamic Links.
private void createFirebaseLink(Uri linkUri){
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(linkUri)
.buildShortDynamicLink()
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
#Override
public void onComplete(#NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
// SHARE BY LOCAL METHODS
} else {
Toast.makeText(getApplicationContext(), R.string.share_error, Toast.LENGTH_LONG).show();
Log.e("FIREBASE_SHORT_LINK", task.getException().getLocalizedMessage());
}
}
});
}
private Uri createDynamicUri(Uri uri){
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(uri)
.setDynamicLinkDomain(getString(R.string.firebase_link_domain))
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
.buildDynamicLink();
return dynamicLink.getUri();
}
private Uri createShareUri(String id) {
Uri.Builder builder = new Uri.Builder();
builder.scheme(getString(R.string.config_scheme))
.authority(getString(R.string.config_host))
//PATH IN THE APP TO ALLOW DIFFERENT ACTIONS
.appendPath(getString(R.string.config_path))
// HERE YOU PUT WHATEVER YOU WANT TO MANAGE IN THE APP,
// REFERRAL CODE FOR EXAMPLE.
.appendQueryParameter("KEY", "VALUE");
return builder.build();
}
You can use them like:
Uri shareItem = createShareUri("Some value");
Uri dynamicLink = createDynamicLink(shareItem);
createFirebaseLink(dynamicLink);
You can get more info in Firebase docs.

Related

App is unable to catch firebase dynamic links redirecting from youtube description

I have few dynamic links and mentioned it in a Youtube video description. When I click on the link separately it opens specific screen in the app as expected but if I click from the youtube description it redirects to the app but not to the specific screen.
This is happening only in the youtube app. If I try from browser it is working as expected.
DynamicLinksActivity is where I catch the dynamic links. I tried to log the link I receive
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
.addOnSuccessListener(this, pendingDynamicLinkData -> {
Uri deeplink = null;
String linkType = "";
Timber.e("%s",pendingDynamicLinkData.toString());
if (null != pendingDynamicLinkData) {
deeplink = pendingDynamicLinkData.getLink();
}
}
When I click from youtube app this activity is not being called.
Is there something am I missing? Suggestions would be appreciated!

Trying to get the dynamic link that opened the app on Android 12 gives incomplete link

I am creating a share button for a post on the feed. I am generating a unique link using Firebase Dynamic Links with a custom parameter at the end. On Android 11 and previous devices, the link was successfully handled and I retrieved the complete link and then extracted the id part from it and then loaded the correct post data using that. But on Android 12, I only get the base part of my link and not the custom parameter that I added. I don't want to change the link generation logic, since the app is already on the Play Store. Can anybody help?
Link Generation Code:
String url = "https://<BASE LINK CONFIGURED IN FIREBASE>/?link=https://<BASE LINK CONFIGURED IN FIREBASE>/&apn=<APP PACKAGE NAME>&afl=<LINK TO APP IN GOOGLE PLAY STORE>&ofl=<LINK TO APP IN GOOGLE PLAY STORE>";
Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(Uri.parse(url))
.buildShortDynamicLink()
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
#Override
public void onComplete(#NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
String link = shortLink.toString();
link += "?id=" + post.getID();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, link);
sendIntent.setType("text/plain");
Intent shareIntent = Intent.createChooser(sendIntent, null);
context.startActivity(shareIntent);
} else {
Toast.makeText(context, "Error creating link", Toast.LENGTH_SHORT).show();
}
}
});
Link reading code when app is opened from dynamic link:
Intent intent = getIntent();
Uri uri = intent.getData();
String uriString = uri.toString(); //Used to contain complete link, but now has only BASE LINK CONFIGURED IN FIREBASE
//Extracting parameter from complete link and further processing like fetching data etc.
Ideally I would like to not change the generation code, but if there is no other way, I guess I will have to change that. Thanks!
So, I finally solved this. Turns out this was not an Android version issue, instead for some reason it was happening only in the release APK and not the debug APK. I finally figured out what was happening. In the debug APK, I was receiving the complete link (https:///?id=), but in the release APK, I was only getting the link parameter of the original link (https:///?link=https:///&apn=&afl=&ofl=). So I added my custom generated link in this link parameter as well and it is working correctly now, both on Android 11 and 12 and on the debug APK as well as on the release APK.

Firebase Dynamic links , Define link behaviour programmatically for Android

I'm working with firebase dynamic links on android to generate links programmaticaly when a user shares a specific content .
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"Subject");
sendIntent.setType("text/plain");
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(Uri.parse("https://organization.page.link/?link=https://www.organization.com/content.htm"))
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
.buildShortDynamicLink()
.addOnCompleteListener((Activity) context, task -> {
if (task.isSuccessful()) {
sendIntent.putExtra(Intent.EXTRA_TEXT, task.getResult().getShortLink());
context.startActivity(Intent.createChooser(sendIntent, "Share")));
}
});
Everything works fine here, except when the receiver of the dynamic link doesn't have the app installed , so it redirects him to the website instead of Play Store. I have tried .setFallbackUrl() but it doesn't work.
I have found the problem:
When I use
.setLongLink(Uri.parse("https://organization.page.link/link=https://www.organization.com/content.htm"))
the link is always resolved, then Android opens the URL instead of Play Store . I have replaced that with
.setLink(Uri.parse("www.organization.com/content.htm"))
And adding
.setDynamicLinkDomain("organization.page.link")
Final code
FirebaseDynamicLinks.getInstance()
.createDynamicLink()
.setLink(Uri.parse("https://organization.com/content.htm"))
.setDynamicLinkDomain("organization.page.link")
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
.buildShortDynamicLink()
.addOnCompleteListener((Activity) context, task -> {
if (task.isSuccessful()) {
// Get Dynamic link here
}
});

firebase dynamic link preview link not working with facebook messenger

Created firebase dynamic short link will not preview correctly in facebook messenger.
It puts up the message and link as expected and shows a preview image with url.
The url included in the message is working but not the url if I click on the preview.
The url should be : https://q3zbm.app.goo.gl/8f7b
but the preview link becomes https://q3zbm.app.goo.gl/s?socialDescription=Welcome&socialImageUrl=http://andreasandersson.nu/images/awesome-photo.jpg&socialTitle=Gooo
I was able to reproduce this in a very small program
private void generate() {
DynamicLink.SocialMetaTagParameters.Builder params = new DynamicLink.SocialMetaTagParameters.Builder();
params.setImageUrl(Uri.parse("http://andreasandersson.nu/images/awesome-photo.jpg"));
params.setDescription("Welcome");
params.setTitle("Gooo");
FirebaseDynamicLinks.getInstance()
.createDynamicLink()
.setLink(Uri.parse("http://andreasandersson.nu"))
.setDynamicLinkDomain("q3zbm.app.goo.gl")
.setIosParameters(new DynamicLink.IosParameters.Builder("ios.app.example").build())
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
//.setSocialMetaTagParameters(params.build())
.buildShortDynamicLink(SHORT)
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
#Override
public void onComplete(#NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
Uri flowchartLink = task.getResult().getPreviewLink();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, "check this:" + shortLink.toString());
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, "share"));
}
}
});
}
I know that the app values are not correct but inputting correct ones gives no difference in the result.
Is this an error on the firebase dynamic link or is the problem with facebook messenger?
When doing the exact same thing from ios it is working as intended which should mean that this is a android related issue with the sharer?
Update: Thanks for contacting FIrebase support. This is an issue with Facebook that we already raised to them. As of now, we are yet to hear any updates from them, but once we do, we'll let you know.
I think that Facebook will not allow this because it would be in violation of their Fake news issue. The ability to change the image used when sharing links was removed and the Firebase meta info would allow you to circumvent this.
Update
After playing around with URL's it turns out I had a trailing "/" before "?" which was preventing the link working with Facebook. Using firebase links we can now set all meta info and provide custom thumbnails again.
I filed the similar question to Firebase support before. According to their support, it seems that it's on Facebook's side and they've filed a bug on Facebook. They also provided the bug tracker (https://business.facebook.com/direct-support/question/124595778189376/?force_full_site=0&business_id=191383518008569) but it appears I don't have necessary access to view the tracker, so I think this might also apply to you.

How to create "Invite Friends" button in android?

I want open this type of window when I click "Invite Friends" button & after selecting any of them I wand paste the link for my app in the selected application
Try below code to share your link:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "YOUR_LINK");
sendIntent.setType("text/plain");
startActivity(sendIntent);
You can see complete example "How to Create Refer a friend Link"
You need to add Firebase Dynamic link(Firebase Invites depreciated now). Firebase Dymanic Link is build over Firebase Invites So you can see the invites dependency on gradle file.
There is Two ways to create "Refer a Friend Link"
Using Firebase base Dynamic Object
Manually Create Refer a Link
1) Option :-
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse("https://www.example.com/"))
//.setDomainUriPrefix("https://example.page.link") // no longer in user please
.setDynamicLinkDomain("example.page.link") // use this code and don't use https:// here
// Open links with this app on Android
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
// Open links with com.example.ios on iOS
.setIosParameters(new DynamicLink.IosParameters.Builder("com.example.ios").build())
.buildDynamicLink();
Uri dynamicLinkUri = dynamicLink.getUri();
2) Option:-
String sharelinktext = "https://referearnpro.page.link/?"+
"link=https://www.blueappsoftware.com/"+
"&apn="+ getPackageName()+
"&st="+"My Refer Link"+
"&sd="+"Reward Coins 20"+
"&si="+"https://www.blueappsoftware.com/logo-1.png";
Then Call ShortDynamicLink Object
Refer Link will be look like this :
https://referearnpro.page.link?apn=blueappsoftware.referearnpro&link=https%3A%2F%2Fwww.blueappsoftware.com%2F
You can check complete example here

Categories

Resources