✨ iOS quick reply (finished)
This commit is contained in:
@@ -38,13 +38,10 @@ target 'Runner' do
|
||||
|
||||
target 'SolarNotifyService' do
|
||||
inherit! :search_paths
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
pod 'home_widget', :path => '.symlinks/plugins/home_widget/ios'
|
||||
pod 'shared_preferences_foundation', :path => '.symlinks/plugins/shared_preferences_foundation/darwin'
|
||||
|
||||
pod 'Kingfisher', '~> 8.0'
|
||||
pod 'Alamofire'
|
||||
end
|
||||
|
||||
target 'SolarWidgetExtension' do
|
||||
@@ -53,7 +50,6 @@ target 'Runner' do
|
||||
use_modular_headers!
|
||||
|
||||
pod 'home_widget', :path => '.symlinks/plugins/home_widget/ios'
|
||||
pod 'shared_preferences_foundation', :path => '.symlinks/plugins/shared_preferences_foundation/darwin'
|
||||
|
||||
pod 'Kingfisher', '~> 8.0'
|
||||
end
|
||||
|
@@ -1,4 +1,5 @@
|
||||
PODS:
|
||||
- Alamofire (5.10.2)
|
||||
- connectivity_plus (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@@ -221,6 +222,7 @@ PODS:
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
- Alamofire
|
||||
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
|
||||
- croppy (from `.symlinks/plugins/croppy/ios`)
|
||||
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
||||
@@ -257,6 +259,7 @@ DEPENDENCIES:
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- Alamofire
|
||||
- DKImagePickerController
|
||||
- DKPhotoGallery
|
||||
- Firebase
|
||||
@@ -343,6 +346,7 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/workmanager/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Alamofire: 7193b3b92c74a07f85569e1a6c4f4237291e7496
|
||||
connectivity_plus: 18382e7311ba19efcaee94442b23b32507b20695
|
||||
croppy: b6199bc8d56bd2e03cc11609d1c47ad9875c1321
|
||||
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
|
||||
@@ -394,6 +398,6 @@ SPEC CHECKSUMS:
|
||||
WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db
|
||||
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6
|
||||
|
||||
PODFILE CHECKSUM: c287205af8b370f21f61cbff93ce745f0157a3c8
|
||||
PODFILE CHECKSUM: 9b244e02f87527430136c8d21cbdcf1cd586b6bc
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import home_widget
|
||||
import Alamofire
|
||||
|
||||
class NotifyDelegate: UIResponder, UNUserNotificationCenterDelegate {
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
@@ -19,21 +20,34 @@ class NotifyDelegate: UIResponder, UNUserNotificationCenterDelegate {
|
||||
let channelId = metadata["channel_id"] as? Int
|
||||
let eventId = metadata["event_id"] as? Int
|
||||
|
||||
let replyToken = metadata["reply_token"] as? String
|
||||
|
||||
if #available(iOS 17, *) {
|
||||
Task {
|
||||
await HomeWidgetBackgroundWorker.run(
|
||||
url: URL(string: "solink:///chat/reply")?.appending(queryItems: [
|
||||
URLQueryItem(name: "channel_id", value: String(channelId ?? 0)),
|
||||
URLQueryItem(name: "event_id", value: String(eventId ?? 0)),
|
||||
URLQueryItem(name: "text", value: textResponse.userText)
|
||||
]),
|
||||
appGroup: "group.solsynth.solian"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
if (channelId == nil || eventId == nil || replyToken == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
let serverUrl = "https://api.sn.solsynth.dev"
|
||||
let url = "\(serverUrl)/cgi/im/quick/\(channelId!)/reply/\(eventId!)?replyToken=\(replyToken!)"
|
||||
|
||||
let parameters: [String: Any] = [
|
||||
"type": "messages.new",
|
||||
"body": [
|
||||
"text": textResponse.userText,
|
||||
"algorithm": "plain"
|
||||
]
|
||||
]
|
||||
|
||||
AF.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default)
|
||||
.validate()
|
||||
.responseString { response in
|
||||
switch response.result {
|
||||
case .success(_):
|
||||
break
|
||||
case .failure(let error):
|
||||
print("Failed to send chat reply message: \(error)")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
completionHandler()
|
||||
|
Reference in New Issue
Block a user