编辑:只是一个更新......我被告知为此提交错误报告(我这样做了)。
我还提供了一段视频,展示了如何重现该错误。
这是支持人员发回的消息...
你好,
感谢您联系 Apple 开发者技术支持 (DTS)。
DTS 无法为反馈 ID #FB9049862 提供解决方法;它仍在调查中。请继续通过错误报告跟踪问题。...
我能够创建一个重现此问题的测试应用程序,我认为需要演示的代码量最少。希望这能提供解决方案!
//
// MessagesViewController.swift
// testGroupSend MessagesExtension
//
import UIKit
import Messages
import os
class MessagesViewController: MSMessagesAppViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
// MARK: - Conversation Handling
func composeSelectionMsg(on conversation: MSConversation, in
session: MSSession) -> MSMessage {
let layout = MSMessageTemplateLayout()
layout.caption = "caption..."
let message = MSMessage(session: session)
message.layout = layout
message.summaryText = "summary text..."
var components = URLComponents()
var queryItems = [URLQueryItem]()
queryItems.append(URLQueryItem(name: "MessageType1", value: "msgType"))
queryItems.append(URLQueryItem(name: "Encode-Name", value: "Encode-Value"))
components.queryItems = queryItems
message.url = components.url!
return message
}
func submitMessage() {
guard let conversation = activeConversation else {
os_log("submitMessage(): guard on conversation falied!", log: .default, type: .debug)
return
}
var session : MSSession
if let tSess = conversation.selectedMessage?.session {
session = tSess
os_log("submitMessage() got a session!...", log: .default, type: .debug)
} else {
os_log("###### submitMessage() did NOT get a session, creating new MSSession() #####", log: .default, type: .debug)
session = MSSession()
}
var message: MSMessage
message = composeSelectionMsg(on: conversation, in: session)
// conversation.insert(message) { error in
conversation.send(message) { error in
if let error = error {
os_log("submitMessage(): initial send error: %@", log: .default, type: .debug, error.localizedDescription)
} else {
os_log("submitMessage(): initial send success!", log: .default, type: .debug)
}
}
}
fileprivate func loadContentView() {
os_log("loadContentView()...", log: .default, type: .debug)
let childViewCtrl = ContentViewHostController()
childViewCtrl.delegate = self
childViewCtrl.view.layoutIfNeeded() // avoids snapshot warning?
if let window = self.view.window {
childViewCtrl.myWindow = window
window.rootViewController = childViewCtrl
}
}
override func willBecomeActive(with conversation: MSConversation) {
loadContentView()
}
override func didResignActive(with conversation: MSConversation) {
os_log("didResignActive()...", log: .default, type: .debug)
}
}
//
//
import SwiftUI
import Messages
import os
final class ContentViewHostController: UIHostingController<ContentView> {
weak var delegate: ContentViewHostControllerDelegate?
weak var myWindow: UIWindow?
init() {
super.init(rootView: ContentView())
rootView.submitMessage = submitMessage
}
required init?(coder: NSCoder) {
super.init(coder: coder, rootView: ContentView())
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
func submitMessage() {
os_log("ContentViewHostController::submitMessage(): submit message...", log: .default, type: .debug)
delegate?.contentViewHostControllerSubmitMessage(self)
}
}
struct ContentView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var submitMessage: (() -> Void)?
var body: some View {
VStack {
VStack {
HStack {
Button(action: { self.cancel() } ) { Image(systemName: "chevron.left") }
.padding()
Spacer()
Button(action: { self.submit() } ) {
Text("Send...")
}
.padding()
} // HStack
} // VStack
} // outside most VStack
} // body
private func cancel() {
presentationMode.wrappedValue.dismiss()
}
private func submit() {
submitMessage!()
presentationMode.wrappedValue.dismiss()
}
} // ContentView
//
//
import SwiftUI
import Messages
import os
extension MessagesViewController: ContentViewHostControllerDelegate {
// MARK: - ContenHost delegate
func contentViewHostControllerSubmitMessage(_ controller: ContentViewHostController) {
os_log("delegateSubmitMessage:...")
submitMessage()
}
}
//
//
import SwiftUI
import Messages
protocol ContentViewHostControllerDelegate: class {
func contentViewHostControllerSubmitMessage( _ controller: ContentViewHostController )
}