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.
Related
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.
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.
My question is directly connected with this one Open Facebook page from Android app? Which answer (for the version at the moment) is not the marked one but this one
public static Intent newFacebookIntent(PackageManager pm, String url) {
Uri uri;
try {
pm.getPackageInfo("com.facebook.katana", 0);
// https://stackoverflow.com/a/24547437/1048340
uri = Uri.parse("fb://facewebmodal/f?href=" + url);
} catch (PackageManager.NameNotFoundException e) {
uri = Uri.parse(url);
}
return new Intent(Intent.ACTION_VIEW, uri);
}
Which is confirmed working last on 7th of February 2015.
My question is should you use the whole url (like www.facebook.com/mypage) or just add the url of the page so it'll be fb://facewebmodal/f?href=mypage. I tried both and it just opens the fb app without an actual page. It shows blank fb page on both tries.
Can someone give me an example with url for some public page that works?
You can try to write mypage as https://www.facebook.com/ID. The whole uri should then be
fb://facewebmodal/f?href=https://www.facebook.com/ID
and change ID to the page you want to visit.
That functionality is not documented or supported, so you may get unknown result. You may want to try passing the Page ID or Profile ID instead of names. You can get the ID by calling https://graph.facebook.com/<name> and parse the result.
I had the same issue. I searched for a while and tried all the answers on here Open facebook page from android app (in facebook version > v11) and there Open Facebook page from Android app?, finally I figured out what the real problem is. There is nothing wrong in the code, however the weird behavior is about facebook app itself. If the facebook app is on the background, it just switches back to the foreground without navigating to the requested page. You just swipe it out from the background (kill instances) and try your code again.
Considering most of the users leave facebook app on the background, this is some kind of an issue needs to be fixed. Although I think it is about the facebook app itself, somehow it can be related with the device. I'm using Nexus 6 with v 6.0.1 and had no chance to test it on another android versioned device.
i using this for my apps its working just fine, kotlin
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/100674618166286"));
startActivity(intent);
} catch(e: Exception) {
startActivity( Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/iqtousd")));
}
Remember have a similar issue.
Try the mobile url :
instead of
String facebookUrl = "https://facebook.com/...";
use
String facebookUrl = "https://m.facebook.com/...";
I have programmatically added Google+ sharing to my app. I have a set of photos that I include with my posts and share with the following code:
private void shareToGooglePlus() {
// Launch the Google+ share dialog with attribution to your app.
PlusShare.Builder share = new PlusShare.Builder(this);
for (String imageFilename : imageList) {
Uri imageUri = Uri.fromFile(new File(imageFilename));
share.addStream(imageUri);
}
share.setText("My images");
share.setType("image/jpeg");
startActivityForResult(share.getIntent(), 0);
}
When this code gets executed, the Google+ app on my phone is started and I get a preview that has the images and text as expected.
However, if I run this more than once and include different images on subsequent runs, the original images show up in the Google+ post preview instead of the new ones. If I submit the post, the correct images show up in the post--the new ones, not the original ones.
I presume the Google+ app has some kind of caching mechanism. Is there a way to programmatically clear that cache so that the correct images show up in the Google+ app post preview?
Thanx in advance.
Try assigning different random names to your source files (by renaming or copying) on each run
I have this code for sharing an app on facebook but when i share it it puts right links but wrong picture of the app
Button bShare = (Button) findViewById(R.id.button7);
bShare.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.myglobaljournal.christmascarol");
startActivity(Intent.createChooser(intent, "Share with"));
You can use the Debug tool to check how facebook "sees" this url.
From the result you can see that there are no og meta tags defined and so facebook probably takes a random picture from the content.
Edit
Facebook uses the open graph meta tags to extract info which is then used to render the share stories on the facebook experience.
You can see an example in the archived version of the Open Graph protocol, the new version uses the tags there but it's too complicated to your needs.
The only question is: can you any control over the output of the google play store for your app?
My guess is that you can't, and if you look at other examples (such as instagram or opera mobile) the image also appears random.