I m trying to send text message which also contains urls to my friends on fb messenger, but not getting any way to send them.
I have tried this
let result = FBSDKMessengerSharer.messengerPlatformCapabilities().rawValue & FBSDKMessengerPlatformCapability.Image.rawValue
if result != 0 {
let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: Urls().WEONE_ITUNES_TINYURL)
content.contentDescription = "Dscription"
content.contentTitle = "Title"
let facebookSendButton: FBSDKSendButton = FBSDKSendButton()
facebookSendButton.shareContent = content
facebookSendButton.sendActionsForControlEvents(UIControlEvents.TouchUpInside)
} else {
Utils().alertView(self, title: "Cannot Send Message", message: "Your device is not able to send Facebook Messenger messages.")
}
but this is only for sharing links
I tried sending message using urlscheme also but it just opens up the fb messenger:
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb-messenger-api://")!) {
var msgString = "Hello World: https://randomurl.com"
let urlStringEncoded = msgString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
var urlString = "fb-messenger://messaging?text=(urlStringEncoded!)"
UIApplication.sharedApplication().openURL(NSURL(string: urlString)!)
}
else {
print("Failed to open fb-messenger App ")
}
In android it is possible by this
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Your message");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.facebook.orca");
try {
startActivity(sendIntent);
} catch (android.content.ActivityNotFoundException ex) {
ToastHelper.show(this, "Please Install Facebook Messenger");
}
This is sent from android
Any help will be appreciated
Thanks in advance
2
Answers
Try this:
Same as Виктор Иванов answer in Swift:
.imageURL, .contentTitle, .contentDescription are now deprecated