I developed App to use iMessage or Message App. I have used MessageUI.I can display message App's contents on modal, but can't press submit(send?) button of the message App on modal. It's pressed but no response.
Why is that? Is there anyone who is worried about the same thing? Please help me.
Content.swift-Excerpt
}).sheet(isPresented: $isShowSheet) {
SMSView(number: UserDefaults.standard.string(forKey: "key") ?? "\(text)")
Message.swift
import SwiftUI
import MessageUI
struct SMSView: UIViewControllerRepresentable {
var number : String
func makeCoordinator() -> Coordinator{
Coordinator(self)
}
func makeUIViewController(context: Context) -> UIViewController {
let composeVC = MFMessageComposeViewController()
if !MFMessageComposeViewController.canSendText() {
print("SMS services are not available")
}else {
composeVC.messageComposeDelegate = context.coordinator
composeVC.recipients = [number] //宛先
composeVC.body = "おはようございます" //本文
}
return composeVC
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
Coordinator.swift
import SwiftUI
import MessageUI
class Coordinator: NSObject,UINavigationControllerDelegate,MFMessageComposeViewControllerDelegate {
var parent: SMSView
init(_ parent:SMSView){
self.parent = parent
}
![]("https://developer.apple.com/forums/content/attachment/e863a009-5a95-4f62-8426-a24844062c60" "title=IMG_0448.jpg;width=1242;height=2208")
func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
controller.dismiss(animated: true, completion: nil)
}
}
on modal - 持ち主 is correct number