From 2ab2a48f02f4bb3d2ff308a0743b7ec7180969c1 Mon Sep 17 00:00:00 2001 From: liyi Date: Tue, 1 Jul 2025 14:22:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:voip=E6=94=B6=E5=88=B0=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8livecommunicationkit=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=AE=9E=E7=8E=B0=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/LCKBridge.swift | 31 +++++++++++++++++++ ios/Runner-Bridging-Header.h | 4 +++ ios/Runner.xcodeproj/project.pbxproj | 36 ++++++++++++++++++++++- ios/Runner/AppDelegate.m | 4 +++ ios/Runner/LCKBridge.swift | 31 +++++++++++++++++++ ios/Runner/RunnerRelease-sky.entitlements | 2 +- 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 ios/LCKBridge.swift create mode 100644 ios/Runner-Bridging-Header.h create mode 100644 ios/Runner/LCKBridge.swift diff --git a/ios/LCKBridge.swift b/ios/LCKBridge.swift new file mode 100644 index 00000000..c53f488e --- /dev/null +++ b/ios/LCKBridge.swift @@ -0,0 +1,31 @@ +import Foundation +import UIKit +import LiveCommunicationKit + +@objc class LCKBridge: NSObject { + @objc static func presentCallInterfaceFromRootVC(_ rootVC: UIViewController, callerName: String) { + if #available(iOS 17.4, *) { + // 配置ConversationManager + let config = ConversationManager.Configuration( + ringtoneName: "notes_of_the_optimistic", + iconTemplateImageData: UIImage(named: "AppIcon")?.pngData(), + maximumConversationGroups: 1, + maximumConversationsPerConversationGroup: 1, + includesConversationInRecents: false, + supportsVideo: false, + supportedHandleTypes: [.generic, .phoneNumber, .emailAddress] + ) + let manager = ConversationManager(configuration: config) + let local = Handle(type: .generic, value: callerName, displayName: callerName) + let update = Conversation.Update(localMember: local, members: [local], activeRemoteMembers: [local]) + Task { + do { + try await manager.reportNewIncomingConversation(uuid: UUID(), update: update) + print("成功报告新来电") + } catch { + print("报告新来电失败: \(error.localizedDescription)") + } + } + } + } +} \ No newline at end of file diff --git a/ios/Runner-Bridging-Header.h b/ios/Runner-Bridging-Header.h new file mode 100644 index 00000000..1b2cb5d6 --- /dev/null +++ b/ios/Runner-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f99d9efd..9a9985d9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 044929092E13AE5D0062AC4D /* LCKBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044929082E13AE5D0062AC4D /* LCKBridge.swift */; }; 04717D692D1B97E100089BD3 /* InfoPlist_sky.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04717D672D1B97E100089BD3 /* InfoPlist_sky.strings */; }; 04717D6D2D1B983300089BD3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04717D6B2D1B983200089BD3 /* InfoPlist.strings */; }; 04717D712D1B9B5A00089BD3 /* InfoPlist_xhj.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04717D6F2D1B9B5A00089BD3 /* InfoPlist_xhj.strings */; }; @@ -100,6 +101,8 @@ /* Begin PBXFileReference section */ 0420903B2C0EEAA50073E654 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; + 044929082E13AE5D0062AC4D /* LCKBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCKBridge.swift; sourceTree = ""; }; + 0449290A2E13AE5F0062AC4D /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 04717D682D1B97E100089BD3 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist_sky.strings"; sourceTree = ""; }; 04717D6A2D1B97E800089BD3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist_sky.strings; sourceTree = ""; }; 04717D6C2D1B983200089BD3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -462,6 +465,7 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( + 044929082E13AE5D0062AC4D /* LCKBridge.swift */, 82F1ED1B2BE8BA8E00265D59 /* BioAuthEngine.bundle */, 82F1ED192BE8BA7D00265D59 /* OCRXMedia.bundle */, 82F1ED172BE8BA6900265D59 /* APBToygerFacadeSuitable.bundle */, @@ -476,6 +480,7 @@ 7EA577AFEEE10224BA96C569 /* preLaunchScreen.storyboard */, 9A03C622761920C324D80733 /* skyLaunchScreen.storyboard */, 6A6F5C86239927252C06A16A /* xhjLaunchScreen.storyboard */, + 0449290A2E13AE5F0062AC4D /* Runner-Bridging-Header.h */, ); sourceTree = ""; }; @@ -606,7 +611,7 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1430; + LastSwiftMigration = 1630; }; }; }; @@ -809,6 +814,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 044929092E13AE5D0062AC4D /* LCKBridge.swift in Sources */, 8297E49B2AE7974700E886FA /* AppDelegate.m in Sources */, 8297E4102AE75AC500E886FA /* XSFlutterManager.m in Sources */, 97C146F31CF9000F007C117D /* main.m in Sources */, @@ -1073,6 +1079,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 4A63B2C308CB401731950EC8 /* Pods-Runner.debug-sky.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-sky.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1092,6 +1099,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-sky"; @@ -1171,6 +1180,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 22D858E988707FF26E068457 /* Pods-Runner.debug-xhj.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-xhj.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1190,6 +1200,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-xhj"; @@ -1198,6 +1210,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 16A83D21DFB231D8453DC681 /* Pods-Runner.release-sky.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-sky.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; @@ -1213,6 +1226,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Release-sky"; @@ -1221,6 +1236,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = CDC2B8ED804B514A774F187D /* Pods-Runner.release-xhj.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-xhj.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -1240,6 +1256,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Release-xhj"; @@ -1467,6 +1485,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 72E2A6A227EA101C0167D322 /* Pods-Runner.debug-local.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerDebug-dev.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1486,6 +1505,9 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-local"; @@ -1565,6 +1587,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D697F91E8405773AB9A5881E /* Pods-Runner.pre-release-sky.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-sky.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -1584,6 +1607,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Pre-release-sky"; @@ -1663,6 +1688,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 126D1370182AB44291C67A10 /* Pods-Runner.dev-release-sky.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-sky.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -1682,6 +1708,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Dev-release-sky"; @@ -1761,6 +1789,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 789004F1B475B44713E199BC /* Pods-Runner.pre-release-xhj.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-xhj.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -1780,6 +1809,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Pre-release-xhj"; @@ -1859,6 +1890,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = ED3A443EA1439FD0FB4BCF80 /* Pods-Runner.dev-release-xhj.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-xhj.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; @@ -1878,6 +1910,8 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h"; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = "Dev-release-xhj"; diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index 92350cc0..107a37cc 100755 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -3,6 +3,7 @@ #import "GeneratedPluginRegistrant.h" #import "CommonDefine.h" #import "XSFlutterManager.h" +#import "Runner-Swift.h" #import #import @@ -189,6 +190,9 @@ - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { if ([type isEqualToString:PKPushTypeVoIP]) { NSLog(@"[VoIP] didReceiveIncomingPushWithPayload: %@", payload.dictionaryPayload); + UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController; + NSString *callerName = @"来电"; // 可根据payload内容自定义 + [LCKBridge presentCallInterfaceFromRootVC:rootVC callerName:callerName]; } if (completion) { completion(); diff --git a/ios/Runner/LCKBridge.swift b/ios/Runner/LCKBridge.swift new file mode 100644 index 00000000..c53f488e --- /dev/null +++ b/ios/Runner/LCKBridge.swift @@ -0,0 +1,31 @@ +import Foundation +import UIKit +import LiveCommunicationKit + +@objc class LCKBridge: NSObject { + @objc static func presentCallInterfaceFromRootVC(_ rootVC: UIViewController, callerName: String) { + if #available(iOS 17.4, *) { + // 配置ConversationManager + let config = ConversationManager.Configuration( + ringtoneName: "notes_of_the_optimistic", + iconTemplateImageData: UIImage(named: "AppIcon")?.pngData(), + maximumConversationGroups: 1, + maximumConversationsPerConversationGroup: 1, + includesConversationInRecents: false, + supportsVideo: false, + supportedHandleTypes: [.generic, .phoneNumber, .emailAddress] + ) + let manager = ConversationManager(configuration: config) + let local = Handle(type: .generic, value: callerName, displayName: callerName) + let update = Conversation.Update(localMember: local, members: [local], activeRemoteMembers: [local]) + Task { + do { + try await manager.reportNewIncomingConversation(uuid: UUID(), update: update) + print("成功报告新来电") + } catch { + print("报告新来电失败: \(error.localizedDescription)") + } + } + } + } +} \ No newline at end of file diff --git a/ios/Runner/RunnerRelease-sky.entitlements b/ios/Runner/RunnerRelease-sky.entitlements index 4e8ae9e6..dad0f4a1 100755 --- a/ios/Runner/RunnerRelease-sky.entitlements +++ b/ios/Runner/RunnerRelease-sky.entitlements @@ -3,7 +3,7 @@ aps-environment - development + production com.apple.developer.associated-domains applinks:lock.skychip.top