fix:voip收到推送使用livecommunicationkit触发推送实现备份

This commit is contained in:
liyi 2025-07-01 14:22:57 +08:00
parent 517b6b6734
commit 2ab2a48f02
6 changed files with 106 additions and 2 deletions

31
ios/LCKBridge.swift Normal file
View File

@ -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)")
}
}
}
}
}

View File

@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

View File

@ -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 = "<group>"; };
044929082E13AE5D0062AC4D /* LCKBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCKBridge.swift; sourceTree = "<group>"; };
0449290A2E13AE5F0062AC4D /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
04717D682D1B97E100089BD3 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist_sky.strings"; sourceTree = "<group>"; };
04717D6A2D1B97E800089BD3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist_sky.strings; sourceTree = "<group>"; };
04717D6C2D1B983200089BD3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@ -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 = "<group>";
};
@ -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";

View File

@ -3,6 +3,7 @@
#import "GeneratedPluginRegistrant.h"
#import "CommonDefine.h"
#import "XSFlutterManager.h"
#import "Runner-Swift.h"
#import <UserNotifications/UserNotifications.h>
#import <PushKit/PushKit.h>
@ -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();

View File

@ -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)")
}
}
}
}
}

View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<string>production</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:lock.skychip.top</string>