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
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
this 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:")
else { return }
if UIApplication.sharedApplication().canOpenURL(messageAppURL) {
UIApplication.sharedApplication().openURL(messageAppURL)
}
make sure to add sms:
to LSApplicationQueriesSchemes
in your Info.plist
let message = "some invitation message" guard let messageAppURL = URL(string: "sms: &body=\(message)") else {return}
–
Leveille With swift3 you can do it like this
if UIApplication.shared.canOpenURL(URL(string:"sms:")!) {
UIApplication.shared.open(URL(string:"sms:")!, options: [:], completionHandler: nil)
}
Here's what will open the Messages app without showing also showing the "send message" composer. I couldn't get the other solutions here to work without showing such a composer, so I figured I'd try to hack it another way:
if let url = URL(string: "messages://"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
Full disclosure: I have only tested this on iOS 14, and I have not tried submitting it to the App Store to see if Apple approves it or not.
ViewController.h
NSString *app = @"Messages.app";
ViewController.m
// https://developer.apple.com/documentation/appkit/nsworkspace?language=objc
- (IBAction)openclick:(id)sender {
NSLog(@"Opening iMessage");
[[NSWorkspace sharedWorkspace] launchApplication:(NSString *)app];
}
© 2022 - 2024 — McMap. All rights reserved.
MFMessageComposeViewController
to openiMessage
? – Ultra