I have implemented the routine to send a link + content to facebook messenger via its MessageDialog API. I have managed to get the link content to appear on the message dialog, but the send button is disabled. I think this is more of a configuration issue than anything else.
I have implemented this in xamarin native ios with the latest xamarin facebook sdk available (v 4.15.1) and I am compiling with the sdk 10.0.
Here is a very basic implementation:
public bool SendMessageViaMessenger(string Text, string Link) {
var content = new ShareLinkContent();
content.SetContentUrl(new NSUrl(Link));
content.ContentTitle = "Here is an invite";
content.ContentDescription = "Test description";
MessageDialog.Show(content, null);
return true;
}
Here is my Info.plist facebook config section:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{my-fb-app-id}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>{my-fb-app-id}</string>
<key>FacebookDisplayName</key>
<string>{my-fb-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
where {my-fb-app-id} was replaced with my facebook app id and {my-fb-app-name} with the app name.
I have also:
checked that my bundle identifier is the exact same string as the one I have put to the facebook app configuration;
added the domain of the link I am sending as an App Domain in the facebook app configuration;
added the domain of the link I am sending as a web site platform;
integrated the app delegate of my app with the one from facebook, via the following code:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
Facebook.CoreKit.ApplicationDelegate.SharedInstance.FinishedLaunching(app, options);
return base.FinishedLaunching(app, options);
}
Any help would be appreciated. Thanks!
So, facebook was actually just blocking my URL. Everything works fine with other urls.
After some deep experimentation with the MessageDialog API, we discovered that facebook expects the url being shared to give back a proper HTML content result with HTTP 200 status. The url I was sharing was actually giving back a 302 status, redirecting the user to an error page. That behavior is thus not accepted as a shareable content by facebook.
It kinda does make sense this type of behavior. What tricked me was the fact that facebook is ok if I share the same content via an Android Intent.
Anyways, now everything is working fine.
Hope this helps anyone with the same problem!
Cheers!