What I want to achieve now is that when the app is not running, upon receiving a notification, it displays an interface similar to CallKit with accept and decline buttons.
Here is part of my code:
@available(iOS 17.4, *)
class LiveCommunicationManager: NSObject, ConversationManagerDelegate {
static let shared = LiveCommunicationManager()
var isInvalidate:Bool = false
var configuration: ConversationManager!
override init() {
let config = ConversationManager.Configuration(
ringtoneName: "notes_of_the_optimistic",
iconTemplateImageData: UIImage(named: "AppIcon")?.pngData(), // 图标的 PNG 数据
maximumConversationGroups: 1, // 最大对话组数
maximumConversationsPerConversationGroup: 1, // 每个对话组内最大对话数
includesConversationInRecents: false, // 是否在通话记录中显示
supportsVideo: false, // 是否支持视频
supportedHandleTypes: [.generic,.phoneNumber,.emailAddress] // 支持的通话类型
)
configuration = ConversationManager.init(configuration: config)
}
func reportIncomingCall(uuid: UUID, callerName: String) {
configuration.delegate = self
let local = Handle(type: .generic, value: callerName, displayName: callerName)
let update = Conversation.Update(localMember: local,members: [local],activeRemoteMembers: [local])
Task{
do {
try await configuration.reportNewIncomingConversation(uuid: uuid, update: update)
print("成功报告新来电")
} catch {
print("报告新来电失败: \(error.localizedDescription)")
}
}
}
func conversationManager(_ manager: ConversationManager, conversationChanged conversation: Conversation) {
print("会话状态改变了")
}
func conversationManagerDidBegin(_ manager: ConversationManager) {
print("会话已经开始了")
manager.delegate = self
}
func conversationManagerDidReset(_ manager: ConversationManager) {
print("会话将要清除了")
}
func conversationManager(_ manager: ConversationManager, perform action: ConversationAction) {
print("会话接听了")
configuration.invalidate()
}
func conversationManager(_ manager: ConversationManager, timedOutPerforming action: ConversationAction) {
print("会话超时了")
}
func conversationManager(_ manager: ConversationManager, didActivate audioSession: AVAudioSession) {
print("会话激活了")
}
func conversationManager(_ manager: ConversationManager, didDeactivate audioSession: AVAudioSession) {
print("会话死亡了")
}
}
在Appdelegate里设置了这些:
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// 在这里处理离线推送通知
completionHandler(.noData) // 返回后台任务完成
if let aps = userInfo["aps"] as? [String: Any],
let alert = aps["alert"] as? [String : Any]{
// 静默推送的处理逻辑
if #available(iOS 17.4, *) {
let manager = LiveCommunicationManager.shared
if manager.isInvalidate { return }
if let msgType = userInfo["msgType"] as? Int{
if msgType == 5{
manager.configuration.invalidate()
}else{
let callerName = alert["title"] as? String ?? "Fanvil"
manager.reportIncomingCall(uuid: UUID(), callerName: callerName)
}
}
}
}
}
Xcode has been configured with the necessary capabilities, such as Background Fetch, Voice over IP, Background Processing, and Push Notification.
The issue now is that sometimes the code works as expected, allowing the app to wake up when not running and displaying the system interface with accept and decline buttons. However, after a few successful attempts, the app stops waking up, and no notification appears. But when I manually open the app, the didReceiveRemoteNotification method gets triggered.
I’d like to know why this stops working after a few times.
General
RSS for tagDelve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is CallKit still not available in certain countries? like China? If it is, is there a way to get a list of countries?
Hello,
I am unable to figure out how I tell the FamilyActivityPicker whether it should show apps installed on my personal device (to be used with AuthorizationCenter.shared.requestAuthorization(for: .individual)) or apps installed on my child’s device (authenticated their phone via AuthorizationCenter.shared.requestAuthorization(for: .child)).
Is there any parameter or SwiftUI modifier I need to apply?
Otherwise, how does the user or the app know which token belongs to them and which token belongs to their child’s device?
Radar: FB17020977
Thanks a lot for your help!
Hi all,
From what I’ve seen on forums and other sources, it appears that nothing can be done to set the contact poster programmatically. Setting the imageData property affects only the thumbnail image. Does anyone know if this is explicitly documented somewhere? I need this information for a POC document. I watched the iOS 17 keynote (where it was introduced), the Platform State of Union, and other WWDC videos, but I couldn’t find any mention of it. The Contacts framework documentation only explains what can be retrieved from this property and doesn’t mention any way to set the contact poster.
If anyone has any information on this, please help!
Thanks in advance!
Hi everyone,
We're using the react-native-device-activity package to implement app blocking via Apple's Screen Time API. The blocking functionality works well: when the user selects apps and taps "Done," those apps get blocked as expected.
However, we're facing an issue with unblocking apps that the user later unselects. Even after the user unchecks some apps and taps "Done" again, those previously selected (now unselected) apps remain blocked and still show the shield.
I have a UIApplicationDelegate, where I want to terminate a live activity (in dynamic island) in applicationWillTerminate. However, ending an activity is asynchronous. When I end it within a Task, it's never called.
i have codes looks like:
import UIKit
import LiveCommunicationKit
@available(iOS 17.4, *)
class LiveCallKit: NSObject, ConversationManagerDelegate {
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, conversationChanged conversation: Conversation) {
}
@available(iOS 17.4, *)
func conversationManagerDidBegin(_ manager: ConversationManager) {
}
@available(iOS 17.4, *)
func conversationManagerDidReset(_ manager: ConversationManager) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, perform action: ConversationAction) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, timedOutPerforming action: ConversationAction) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, didActivate audioSession: AVAudioSession) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, didDeactivate audioSession: AVAudioSession) {
}
@objc public enum InterfaceKind : Int, Sendable, Codable, Hashable {
/// 拒绝/挂断
case reject
/// 接听.
case answer
}
var sessoin: ConversationManager
var callId: UUID
var completionHandler: ((_ actionType: InterfaceKind,_ payload: [AnyHashable : Any]) -> Void)?
var payload: [AnyHashable : Any]?
@objc init(icon: UIImage!) {
let data:Data = icon.pngData()!;
let cfg: ConversationManager.Configuration = ConversationManager.Configuration(ringtoneName: "ring.mp3",
iconTemplateImageData: data,
maximumConversationGroups: 1,
maximumConversationsPerConversationGroup: 1,
includesConversationInRecents: false,
supportsVideo: false,
supportedHandleTypes: Set([Handle.Kind.generic]))
self.sessoin = ConversationManager(configuration: cfg)
self.callId = UUID()
super.init()
self.sessoin.delegate = self
}
@objc func toIncoming(_ payload: [AnyHashable : Any], displayName: String,actBlock: @escaping(_ actionType: InterfaceKind,_ payload: [AnyHashable : Any])->Void) async {
self.completionHandler = actBlock
do {
self.payload = payload
self.callId = UUID()
var update = Conversation.Update(members: [Handle(type: .generic, value: displayName, displayName: displayName)])
let actNumber = Handle(type: .generic, value: displayName, displayName: displayName)
update.activeRemoteMembers = Set([actNumber])
update.localMember = Handle(type: .generic, value: displayName, displayName: displayName);
update.capabilities = [ .playingTones ];
try await self.sessoin.reportNewIncomingConversation(uuid: self.callId, update: update)
try await Task.sleep(nanoseconds: 2000000000);
} catch {
}
}
}
i want to listen the button event,but i can't find the solutions!please give me a code demo
I am developing a macOS word-processing app that should be distributed via the Apple App Store. Some of the app's functions like generating HTML and PDF exports should be automatable via Shortcuts and via shell scripts.
To support the latter, I plan to include a command line tool inside the app that can be called from the Terminal or a shell script. The tool should be able to instruct the main app to then perform the desired commands.
A well-known AppStore app that uses this design is BBEdit which also contains multiple command line tools that offer functionality from the main app to users of the Terminal.
My technical questions now are:
Should the command line tool executable be sandboxed and if yes, how?
Even after many trials, I have not found a way to make a working sandboxed command line tool. If a sandboxed tool is started from the Terminal, it is immediately terminated with an exception in _libsecinit_appsandbox.cold.12. I am aware of the Apple developer documentation article Embedding A Helper Tool In A Sandboxed App, but it addresses a different architecture in which the helper tool is started from the main app and therefore is able to inherit its sandbox.
BBEdit is only sandboxing the main app, but not its embedded command line tools and is still allowed in the App Store. Is this the way to go for me as well or does BBEdit get some special treatment in the App Store?
How can the command line tool pass the permission to access files to the main app?
As my main app is sandboxed, it needs explicit permission from the user to be able to access files. Users of a command line tool give this permission by providing file paths as arguments. How can I pass these permissions along to the main app? BBEdit is able to do this even when the user has not given it full-disk access. I know that it is using Apple Events for the communication between the command line tool and the main app, but I am not sure how this allows to pass permissions. Can anyone shed light on how to implement a solution here?
Thanks!
Widgets on the widget is not responding to the touch properly. This issue is also affecting within the home screen widget in a way that the widget switches to light mode by itself even though I am in dark mode. Additionally, lock screen does not to respond once the lock screen widget has been edited. Is anyone else having this issue?
hi
where do we need to upload documents and video for the sharing URL for the apple to review while submitting the APP .
Topic:
App & System Services
SubTopic:
General
where can we find documentation on the following fields included in payloads? They're not listed alongside the other fields in the documentation linked below:
https://developer.apple.com/documentation/weatherkitrestapi/hourweatherconditions
precipitationIntensity
snowfallAmount
Or if we can get the data type, unit used, and description here that would be great
I've been stuck for days trying to figure out how to extract the full text of a Siri prompt that launches my app. We need to be able to get the text of the full command, such as "Hey siri, buy dogfood...." so I can get "dogfood" or anything else following 'buy' . The examples I am finding are a) out of date or b) incomplelete. Right now we're using AppIntents with Shortcuts, but have to use dedicated shortcuts for each specific purchase, which are obviously very limiting.
Hi everyone,
We’re integrating Apple Calendar (iCalendar) into our Codapet app but haven’t found any official Apple APIs for event management and synchronisation.
Currently, we use CalDAV with Apple ID authentication and an app-specific password (ASP), storing the ASP encrypted in our database and decrypting it for each API call. We’re looking for a more secure and recommended approach to this integration.
Does Apple provide dedicated APIs for calendar sync, or is there a better alternative to avoid sending the ASP with every request? Any guidance or best practices would be greatly appreciated!
Thanks!
I recently tried Apple TV after using android tv for a long time.
The main missing item is having a browser. I could not find one.
i tried building Firefox for TVOS, it failed with WebKit not available.
Is there a way to build WebKit and package it along with a browser package while building it?
Hello everyone,
I’m currently developing an app that uses the Family Controls API, specifically the Screen Time API. However, my current entitlement is limited to development mode, which prevents me from publishing my app on TestFlight.
I have already contacted Apple Developer Support for production access but wanted to reach out to the community as well and I was referenced to FamilyControls API documentation and I couldn't find anything related to my case. Has anyone successfully upgraded their entitlement from development-only to production? Any insights on the process, tips for communicating with Developer Support, or guidance on ensuring full compliance with the Family Controls guidelines would be extremely helpful.
Question:
A very small number of users experience this crash:
NSInternalInconsistencyException:Use of the class INVocabulary requires the entitlement com.apple.developer.siri.
Make sure you have enabled the Siri capability in your Xcode project.
But our project definitely has siri configured to be available.
During app startup, calling the following code causes a crash:
INVocabulary *vocabulary = [INVocabulary sharedVocabulary];
Now that we can't figure it out, is it a bug in the system?
The example database/server provided by Apple for Live Caller ID contains a hardcoded database with a tiny number of pre-defined numbers.
However, its not expected to be representational of an live real world usage server.
But the question is how can that be accomplished if its a requirement that the data be KPIR encrypted?
In real world scenarios, the factors that effect whether a number should be blocked or not are continually changing and evolving on a minute-by-minute basis and new information becomes available or existing information changes.
If the database supports tens of millions or hundreds of millions of constantly changing phone numbers, in order to meet the requirements of the Live Caller ID being KPIR encrypted, that would imply the database has to re-encrypt its database of millions endlessly for all time.
That seems unfeasable and impractical to implement.
Therefore how do the Apple designers of this feature envisage/suggest a real-world server supporting millions of changing data should meet the requirement to be KPIR encrypted?
Hi there, I'm facing an issue when disconnecting CarPlay that the navigation session seems to be in some weird state where it is not properly finished. So when I reconnect CarPlay the "Metadata in instrument cluster or HUD" does not update anymore until I start another navigation session and stop that one.
You can see that the instruction to the left on this screen recording is not updating anymore after a reconnect.
https://www.youtube.com/watch?v=sncxyJULjQk
I have a modified the CostalRoad sample app to add support for the HUD cluster and to auto start a navigation simulation when CarPlay connects.
https://github.com/g4rb4g3/CoastalRoads
Can anyone tell me what I have to do when CarPlay disconnect so I can start a new navigation session on reconnect that has a working HUD cluster?
Fun fact is that Apple Maps handles this quite nice (https://www.youtube.com/watch?v=OpJEIyGcwdo), it somehow manages to finish the navigation session and brings up the HUD cluster just fine on reconnect.
I wonder how I can achieve the same, anyone having an idea on that?
Hi,
I have a question about On-Demand Resources, I tried to put some bundles into the Initial Install Tags and Download Only On Demand, and I uploaded the build to TestFlight, then I tried to make 2 builds, and the sample is like this:
Build A:
Initial Install Tags have 100 Tags.
Download Only On Demand have 5 Tags.
Build B:
all contents of Initial Install Tags are the same as in Build A.
Download Only On Demand are the same as Build A but I added 5 more tags, so the total is 10 tags, 5 tags that are the same as Build A and 5 new tags.
Then I tried to download Build A for the first time which is in TestFlight, and it runs normally, Initial Install Tags are downloaded when the main app is downloaded and Download Only On Demand is downloaded when I request the tag.
However, when I tried to update to Build B which is in TestFlight, why are the Initial Install Tags deleted? and why should it be downloaded via request? not when the main app is downloaded? has anyone ever experienced something like this?
Thanks!
Hi,
My iphone 12 has been restarting unexpectedly, and often followed by wifi, bluetooth, and airdrop grayed out. I had to force restart/shutdown several times to turn it on again.
Found this analytics after crash. Please help if somebody know what this means:
ExcUserFault_CategoriesService-2024-12-23-064503.ips