🐛 Fix iOS

This commit is contained in:
2026-01-17 23:36:03 +08:00
parent bc4fddc164
commit a02f2fe3c6
3 changed files with 94 additions and 96 deletions

View File

@@ -127,8 +127,6 @@ PODS:
- nanopb (~> 3.30910.0) - nanopb (~> 3.30910.0)
- PromisesSwift (~> 2.1) - PromisesSwift (~> 2.1)
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_app_intents (0.1.0):
- Flutter
- flutter_app_update (0.0.1): - flutter_app_update (0.0.1):
- Flutter - Flutter
- flutter_inappwebview_ios (0.0.1): - flutter_inappwebview_ios (0.0.1):
@@ -264,9 +262,6 @@ PODS:
- Flutter - Flutter
- pasteboard (0.0.1): - pasteboard (0.0.1):
- Flutter - Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.3.0): - permission_handler_apple (9.3.0):
- Flutter - Flutter
- pointer_interceptor_ios (0.0.1): - pointer_interceptor_ios (0.0.1):
@@ -349,7 +344,6 @@ DEPENDENCIES:
- firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`) - firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_app_intents (from `.symlinks/plugins/flutter_app_intents/ios`)
- flutter_app_update (from `.symlinks/plugins/flutter_app_update/ios`) - flutter_app_update (from `.symlinks/plugins/flutter_app_update/ios`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
@@ -373,7 +367,6 @@ DEPENDENCIES:
- native_exif (from `.symlinks/plugins/native_exif/ios`) - native_exif (from `.symlinks/plugins/native_exif/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- pasteboard (from `.symlinks/plugins/pasteboard/ios`) - pasteboard (from `.symlinks/plugins/pasteboard/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`) - pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
- protocol_handler_ios (from `.symlinks/plugins/protocol_handler_ios/ios`) - protocol_handler_ios (from `.symlinks/plugins/protocol_handler_ios/ios`)
@@ -447,8 +440,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_messaging/ios" :path: ".symlinks/plugins/firebase_messaging/ios"
Flutter: Flutter:
:path: Flutter :path: Flutter
flutter_app_intents:
:path: ".symlinks/plugins/flutter_app_intents/ios"
flutter_app_update: flutter_app_update:
:path: ".symlinks/plugins/flutter_app_update/ios" :path: ".symlinks/plugins/flutter_app_update/ios"
flutter_inappwebview_ios: flutter_inappwebview_ios:
@@ -491,8 +482,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios" :path: ".symlinks/plugins/package_info_plus/ios"
pasteboard: pasteboard:
:path: ".symlinks/plugins/pasteboard/ios" :path: ".symlinks/plugins/pasteboard/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple: permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios" :path: ".symlinks/plugins/permission_handler_apple/ios"
pointer_interceptor_ios: pointer_interceptor_ios:
@@ -553,7 +542,6 @@ SPEC CHECKSUMS:
FirebaseRemoteConfigInterop: 3443b8cb8fffd76bb3e03b2a84bfd3db952fcda4 FirebaseRemoteConfigInterop: 3443b8cb8fffd76bb3e03b2a84bfd3db952fcda4
FirebaseSessions: 2e8f808347e665dff3e5843f275715f07045297d FirebaseSessions: 2e8f808347e665dff3e5843f275715f07045297d
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_app_intents: e77f999f398c841ab584a1925dbce33ee0168fb5
flutter_app_update: 816fdb2e30e4832a7c45e3f108d391c42ef040a9 flutter_app_update: 816fdb2e30e4832a7c45e3f108d391c42ef040a9
flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99 flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99
flutter_keyboard_visibility: 4625131e43015dbbe759d9b20daaf77e0e3f6619 flutter_keyboard_visibility: 4625131e43015dbbe759d9b20daaf77e0e3f6619
@@ -585,7 +573,6 @@ SPEC CHECKSUMS:
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
pasteboard: 49088aeb6119d51f976a421db60d8e1ab079b63c pasteboard: 49088aeb6119d51f976a421db60d8e1ab079b63c
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
pointer_interceptor_ios: da06a662d5bfd329602b45b2ab41bc0fb5fdb0f0 pointer_interceptor_ios: da06a662d5bfd329602b45b2ab41bc0fb5fdb0f0
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47

View File

@@ -9,78 +9,76 @@ import AppIntents
@available(iOS 16.0, *) @available(iOS 16.0, *)
struct AppShortcuts: AppShortcutsProvider { struct AppShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] { @AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
[ AppShortcut(
AppShortcut( intent: OpenChatIntent(),
intent: OpenChatIntent(), phrases: [
phrases: [ "Open chat with \(.applicationName)",
"Open chat with \(.applicationName)", "Go to chat using \(.applicationName)",
"Go to chat using \(.applicationName)", "Show chat in \(.applicationName)"
"Show chat in \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: OpenPostIntent(),
intent: OpenPostIntent(), phrases: [
phrases: [ "Open post with \(.applicationName)",
"Open post with \(.applicationName)", "Show post using \(.applicationName)"
"Show post using \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: OpenComposeIntent(),
intent: OpenComposeIntent(), phrases: [
phrases: [ "Open compose with \(.applicationName)",
"Open compose with \(.applicationName)", "New post using \(.applicationName)",
"New post using \(.applicationName)", "Write post in \(.applicationName)"
"Write post in \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: SearchContentIntent(),
intent: SearchContentIntent(), phrases: [
phrases: [ "Search in \(.applicationName)",
"Search in \(.applicationName)", "Find content using \(.applicationName)"
"Find content using \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: CheckNotificationsIntent(),
intent: CheckNotificationsIntent(), phrases: [
phrases: [ "Check notifications with \(.applicationName)",
"Check notifications with \(.applicationName)", "Get notifications using \(.applicationName)",
"Get notifications using \(.applicationName)", "Do I have notifications in \(.applicationName)"
"Do I have notifications in \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: SendMessageIntent(),
intent: SendMessageIntent(), phrases: [
phrases: [ "Send message with \(.applicationName)",
"Send message with \(.applicationName)", "Post message using \(.applicationName)",
"Post message using \(.applicationName)", "Send text using \(.applicationName)"
"Send text using \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: ReadMessagesIntent(),
intent: ReadMessagesIntent(), phrases: [
phrases: [ "Read messages with \(.applicationName)",
"Read messages with \(.applicationName)", "Get chat using \(.applicationName)",
"Get chat using \(.applicationName)", "Show messages with \(.applicationName)"
"Show messages with \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: CheckUnreadChatsIntent(),
intent: CheckUnreadChatsIntent(), phrases: [
phrases: [ "Check unread chats with \(.applicationName)",
"Check unread chats with \(.applicationName)", "Do I have messages using \(.applicationName)",
"Do I have messages using \(.applicationName)", "Get unread messages with \(.applicationName)"
"Get unread messages with \(.applicationName)" ]
] )
), AppShortcut(
AppShortcut( intent: MarkNotificationsReadIntent(),
intent: MarkNotificationsReadIntent(), phrases: [
phrases: [ "Mark notifications read with \(.applicationName)",
"Mark notifications read with \(.applicationName)", "Clear notifications using \(.applicationName)",
"Clear notifications using \(.applicationName)", "Mark all read with \(.applicationName)"
"Mark all read with \(.applicationName)" ]
] )
)
]
} }
} }

View File

@@ -46,7 +46,7 @@ final class NetworkService {
func markNotificationsRead() async throws { func markNotificationsRead() async throws {
let url = try buildUrl(path: SharedConstants.API.notificationsMarkRead) let url = try buildUrl(path: SharedConstants.API.notificationsMarkRead)
let _: EmptyResponse = try await post(url: url, body: nil) let _: EmptyResponse = try await post(url: url)
} }
func getUnreadChatsCount() async throws -> Int { func getUnreadChatsCount() async throws -> Int {
@@ -92,15 +92,28 @@ final class NetworkService {
return try decoder.decode(T.self, from: data) return try decoder.decode(T.self, from: data)
} }
private func post<T: Decodable, B: Encodable>(url: URL, body: B?) async throws -> T { private func post<T: Decodable>(url: URL) async throws -> T {
var request = URLRequest(url: url) var request = URLRequest(url: url)
request.httpMethod = "POST" request.httpMethod = "POST"
authHeaders.forEach { request.setValue($1, forHTTPHeaderField: $0) } authHeaders.forEach { request.setValue($1, forHTTPHeaderField: $0) }
if let body = body { let (data, response) = try await session.data(for: request)
request.httpBody = try JSONEncoder().encode(body) try validateResponse(response)
if T.self == EmptyResponse.self {
return EmptyResponse() as! T
} }
return try decoder.decode(T.self, from: data)
}
private func post<T: Decodable, B: Encodable>(url: URL, body: B) async throws -> T {
var request = URLRequest(url: url)
request.httpMethod = "POST"
authHeaders.forEach { request.setValue($1, forHTTPHeaderField: $0) }
request.httpBody = try JSONEncoder().encode(body)
let (data, response) = try await session.data(for: request) let (data, response) = try await session.data(for: request)
try validateResponse(response) try validateResponse(response)
@@ -131,19 +144,19 @@ enum NetworkError: Error {
case httpError(statusCode: Int) case httpError(statusCode: Int)
} }
private struct NotificationCountResponse: Decodable { struct NotificationCountResponse: Decodable {
let count: Int let count: Int
} }
private struct UnreadChatsResponse: Decodable { struct UnreadChatsResponse: Decodable {
let unreadCount: Int let unreadCount: Int
} }
private struct MessagesResponse: Decodable { struct MessagesResponse: Decodable {
let messages: [MessageResponse] let messages: [MessageResponse]
} }
private struct MessageResponse: Decodable { struct MessageResponse: Decodable {
let content: String? let content: String?
let sender: SenderResponse? let sender: SenderResponse?
@@ -156,9 +169,9 @@ private struct MessageResponse: Decodable {
} }
} }
private struct SendMessageBody: Encodable { struct SendMessageBody: Encodable {
let content: String let content: String
let nonce: String let nonce: String
} }
private struct EmptyResponse: Decodable {} struct EmptyResponse: Decodable {}