Ответ 1
Существует такая функция, но она существует только в SDK для Facebook.
Посмотрите на это - https://developers.facebook.com/docs/ios/share#message-dialog
Кто-нибудь знает, как я могу открыть приложение-мессенджер Facebook с предварительно заполненным текстом?
Например, чтобы открыть приложение-мессенджер у указанного пользователя, вы можете написать следующее:
NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER_ID"];
if ([[UIApplication sharedApplication] canOpenURL: fbURL]) {
[[UIApplication sharedApplication] openURL: fbURL];
}
Для приложений Whats очень просто:
NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@", @"String to post here"]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
Существует такая функция, но она существует только в SDK для Facebook.
Посмотрите на это - https://developers.facebook.com/docs/ios/share#message-dialog
Swift 4 & 5
private func inviteViaFacebook() {
let id = "akbarkhanshinwar"
// If you have User id the use this URL
let urlWithId = "fb-messenger://user-thread/\(id)"
// If you don't have User id then use this URL
let urlWithoutId = "fb-messenger://user-thread"
if let url = URL(string: urlWithId) {
// this will open your Messenger App
UIApplication.shared.open(url, options: [:], completionHandler: {
(success) in
if success == false {
// If Messenger App is not installed then it will open browser.
// If you have User id the use this URL
let urlWithIdForBrowser = "https://m.me/\(id)"
// If you don't have User id then use this URL
let urlWithoutIdForBrowser = "https://m.me"
let url = URL(string: urlWithIdForBrowser)
if UIApplication.shared.canOpenURL(url!) {
UIApplication.shared.open(url!)
}
}
})
}
}