Vlad Hatko Vlad Hatko - 25 days ago 11
iOS Question

Open iMessage from my application

Is there any way to open iMessage apple app from my app? I don't need any composers, the main idea is to open actual iMessage with my extension.

EDITED

I don't want to send any messages; I need only iMessage App to be opened

Answer

his can be done as follows (in Swift 2):

let phoneNumber = "958585858"
let text = "Some message"

guard let messageURL = NSURL(string: "sms:\(phoneNumber)&body=\(text)") 
else { return }
if UIApplication.sharedApplication().canOpenURL(messageURL) {
    UIApplication.sharedApplication().openURL(messageURL)
}

and if you only need to open messages app :

guard let messageAppURL = NSURL(string: "sms:")
if UIApplication.sharedApplication().canOpenURL(messageURL) {
    UIApplication.sharedApplication().openURL(messageURL)
}

make sure to add sms: to LSApplicationQueriesSchemes in your Info.plist