Reputation: 15
I'm developing an iOS app with swift and I need to share a message with the telegram app when a button is pressed. I want the user to choose which contact he/she wants to share the message with.
I've tried the "tg://msg?text=" schema but it only opens telegram not the sharing page to choose a contact.
Does anyone know a way for doing this?
Thank you in advance for your help !
Answer:
As @Cesare pointed out the tg://msg?text=test URL had been disabled by telegram so we need a specific phone number to share the message with.
Upvotes: 0
Views: 4751
Reputation: 57060
Another solution would be to use something like my LNExtensionExecutor
, which allows you to bypass the UIActivityViewController
and execute the standard Telegram (or any other) share extension, providing text and/or images as input items.
Upvotes: 1
Reputation: 9419
Telegram disabled the tg://msg?text=test
URI. You can only send direct messages to pre-chosen users or contacts.
So you may want to present a standard contact list and then send a message to that phone number (assuming they have Telegram).
For sure if you use a UIActivityController
that should work.
@objc func didSelectShareRow() {
let text = "Hello"
let textShare = [text]
let activityViewController = UIActivityViewController(activityItems: textShare , applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
Upvotes: 1