|
@@ -2,6 +2,7 @@ import Foundation
|
|
import UIKit
|
|
import UIKit
|
|
import MobileCoreServices
|
|
import MobileCoreServices
|
|
import AVFoundation
|
|
import AVFoundation
|
|
|
|
+import Intents
|
|
|
|
|
|
public struct DcUtils {
|
|
public struct DcUtils {
|
|
|
|
|
|
@@ -13,6 +14,34 @@ public struct DcUtils {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static func donateSendMessageIntent(chatId: Int) {
|
|
|
|
+ if #available(iOS 13.0, *) {
|
|
|
|
+ let chat = DcContext.shared.getChat(chatId: chatId)
|
|
|
|
+ let groupName = INSpeakableString(spokenPhrase: chat.name)
|
|
|
|
+
|
|
|
|
+ let sendMessageIntent = INSendMessageIntent(recipients: nil,
|
|
|
|
+ content: nil,
|
|
|
|
+ speakableGroupName: groupName,
|
|
|
|
+ conversationIdentifier: "\(chat.id)",
|
|
|
|
+ serviceName: nil,
|
|
|
|
+ sender: nil)
|
|
|
|
+
|
|
|
|
+ // Add the user's avatar to the intent.
|
|
|
|
+ if let imageData = chat.profileImage?.pngData() {
|
|
|
|
+ let image = INImage(imageData: imageData)
|
|
|
|
+ sendMessageIntent.setImage(image, forParameterNamed: \.speakableGroupName)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Donate the intent.
|
|
|
|
+ let interaction = INInteraction(intent: sendMessageIntent, response: nil)
|
|
|
|
+ interaction.donate(completion: { error in
|
|
|
|
+ if error != nil {
|
|
|
|
+ DcContext.shared.logger?.error(error.debugDescription)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
static func copyAndFreeArray(inputArray: OpaquePointer?) -> [Int] {
|
|
static func copyAndFreeArray(inputArray: OpaquePointer?) -> [Int] {
|
|
var acc: [Int] = []
|
|
var acc: [Int] = []
|
|
let len = dc_array_get_cnt(inputArray)
|
|
let len = dc_array_get_cnt(inputArray)
|