Post

Replies

Boosts

Views

Activity

How can a notification service extension receive a VoIP push? (as opposed to receiving a non-VoIP push)
0 If a voip push (i.e. a push with a topic of com.company.app.voip as the push topic) is sent to a handset then it is delivered directly to the app via: pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler: If the app has a notification service extension, and the push payload contains mutable-content, and if the app is terminated, then the app gets launched in the background and the push still is delivered directly to the app, it does not get delivered to the extension. If the push topic is changed to be just com.company.app (and provided the payload contains the mutable-content flag) then in that case it gets delivered to the extension. However now it's no longer a voip push, it's just a regular push, because the topic no longer contains the .voip suffix. So how can things be configured whereby a voip push gets delivered to a notification service extension? Because that's what the Apple documentation says: Call this method when your notification service extension receives an encrypted VoIP call request. From: https://developer.apple.com/documentation/callkit/cxprovider/3727263-reportnewincomingvoippushpayload How is that possible, how can a notification service extension receive an encrypted VoIP call request like it mentions in the documentation?
1
0
1.5k
Nov ’22
Why is the VoIP background mode capability still present in Xcode when it was deprecated in iOS 10?
There's lots of material on the internet talking about how the VoIP background mode capability was deprecated in iOS 10. And yet its still presented as an option in the latest version of Xcode and it still appears in Apple's documentation https://developer.apple.com/documentation/xcode/configuring-background-execution-modes The documentation states: The app provides Voice over IP services and requires automatic launch after system restart. For more information, see the CallKit framework. It seems apps used to be able to be launched on restart prior to iOS 10, but since then they can't. So is the documentation for this area out of date and wrong? If its been deprecated for so long, why is it still documented and possible to add it to an application?
1
0
1.1k
Dec ’22
Is it possible to catch a memory exception in an extension?
I've got a notification service extension with quite a lot going on, and consequently I've been running out of memory. One thing in particular that is using a lot of memory is UIGraphicsImageRenderer which I'm using to construct an image at run time the size of the device's bounds. Running the extension in Xcode and profiling its memory it appears that using autoreleasepool {} doesn't seem to always release memory instantly, so if you do A and then B, and combined they have too much memory usage for the extension to handle, trying to autorelease A doesn't actually always release the memory before B (unlike if the code is running in the main app rather than an extension). A few questions is there any way of programmatically detecting the memory usage / memory limit within the extension? if the extension goes over the 24Mg limit, is there any way of catching that exception and handling it somehow? is there a way of ensuring/forcing autoreleasepool{} to clear memory before proceeding with further code?
1
1
759
Dec ’22
[__NSCFType set]: unrecognized selector with NSAttributedString:draw() gets called, based on width of position
If the code below is run it causes an exception 'NSInvalidArgumentException', reason: '-[__NSCFType set]: unrecognized selector sent to instance 0x283130be0' However, the exception can be removed by reducing the width value from 100.0 in positionRect, for example setting it to something like 50.0 removes the exception. But why is this? With a width value of 100.0 specified for positionRect, that's well short of the width of imageSize. And even if there is some size issue, why is there an unrecognized selector exception? let imageSize = CGSize(width: 400, height: 100) let testRenderer = UIGraphicsImageRenderer(size: imageSize) let testImage = testRenderer.image { context in context.cgContext.setFillColor(UIColor.black.cgColor) context.fill(CGRect(origin: .zero, size: imageSize)) let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .left let attributes: [NSAttributedString.Key: Any] = [ .font: UIFont.systemFont(ofSize: 8.0), .paragraphStyle: paragraphStyle, .foregroundColor: UIColor.white.cgColor ] let attributedString = NSAttributedString(string: "This is some text", attributes: attributes) let positionRect = CGRect(x: 10, y: 10, width: 100.0, height: 8.0) attributedString.draw(with: positionRect, options: .usesLineFragmentOrigin, context: nil) }
1
0
1.5k
Jan ’23
Is it possible to schedule a timer in a notification service extension?
I'm trying to fire a timer in a notification service extension, but what would work in the app doesn't work in the extension i.e. Timer.scheduledTimer(timeInterval: 8.0, target: self, selector: #selector(doSomeStuff2), userInfo: nil, repeats: false) or Timer.scheduledTimer(withTimeInterval: 7.0, repeats: false) { timer in ... } and so on, etc. Is that a way of getting a timer to fire in an extension?
1
0
1.4k
Apr ’23
CFBundleIdentfier Collision uploading app with 3rd party xcframework
using an xcframework supplied by 3rd party. I can build/run/install the app and use the framework without issue when running/installing from Xcode. However if I create an archive and then attempt to upload it to TestFlight I get two errors, the first is: CFBundelIdentifer Collision. There is more than one bundle with the CFBundelIdentifer value bundleidofframework under the application And the second is Invalid Bundle. The bundle at ...myextension.appex contains disallowed file Frameworks. (I'm using the framework within both the app and an extension) Within the embed frameworks section of Xcode, the tickbox code sign on copy is ticked (that's the default value and if its unticked then the app doesn't run when installed directly via Xcode).
1
0
541
May ’23
CallKit call extension invoked twice by the OS in iOS 17 beta
If you create a CallKit extension with Xcode 15 beta, then add some logging to the template code that gets created and run it on an iOS 17.3 beta phone the logging clearly shows that the OS is running the extension twice when the user turns on the extension in Settings. Run it on any device with < iOS 17 and its only invoked once, as it should be. However, not only does the OS run it twice, but based on the logging the two invocations are in parallel, not serial, suggesting two CallDirectoryHandler instances are being created and run simultaneously.
1
1
748
Jul ’23
When does a notification service extension process get terminated?
If there is the following code for a notification service extension var countOfInvocations = 0 public class NotificationService: UNNotificationServiceExtension { public override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -&gt; Void) { NSLog("Push count: \(countOfInvocations)") countOfInvocations = countOfInvocations + 1 Then if pushes are sent to the handset it can be observed in the console log that the value of countOfInvocations keeps increasing, meaning the NotificationService class is getting instantiated and destroyed within the same process. However at what point does that process get torn down by the OS? It seems to be kept alive for about 10 minutes or so. Is there a way the extension can detect its the same or a new process?
1
0
618
Jul ’23
OSLog: anyway to get unified/combined logging from app and app extensions?
I've got a complex app extension and I'd like to be able to combine the logging from the app and the extension into a single file (for extraction/uploading etc.) I experimented adding the following code to both the app and the extension i.e. using the same subsystem for both app and extension logging. let subsystem = "mySubsystem" let logger = Logger(subsystem: subsystem, category: "main") logger.info("Log from within extension") // the version in the app says Log from within app do { let logStore = try OSLogStore(scope: .currentProcessIdentifier) let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try logStore.getEntries(at: oneHourAgo) let filtered = allEntries .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == subsystem } } The filtered content only contains logging from either the app or the extension. I suppose the issue might be the use of .currentProcessIdentifier as the scope, however that's the only scope that is defined. Is what is being attempted here possible? Is there any way to write to and extract a unified log for an app and app extension? If not, how about adding it, surely this would be something useful for people to be able to do
1
0
696
Aug ’23
CXProvider.reportNewIncomingVoIPPushPayload() behavior changed with iOS 16.6
I've been successfully using CXProvider.reportNewIncomingVoIPPushPayload() as follows: a (non VoIP) push is sent to the handset this is intercepted by a notification service extension the extension calls CXProvider.reportNewIncomingVoIPPushPayload() (the extension has the required com.apple.developer.usernotifications.filtering entitlement) this results in the app delegate's implementation of PKPushRegistryDelegate:didReceiveIncomingPushWithPayload getting called (the app is launched if terminated) This all works as expected, in particular when the app is terminated it still works. However its suddenly stopped working since my phone got updated to iOS 16.6 (I can't remember exactly what was on it previously, 16.5 or 16.4). Now with iOS 16.6 the behavior is that PKPushRegistryDelegate:didReceiveIncomingPushWithPayload() only gets called if the app is not terminated. If the app is terminated then calling CXProvider.reportNewIncomingVoIPPushPayload() results in the app getting launched and didFinishLaunchingWithOptions() getting called BUT didReceiveIncomingPushWithPayload() is not called when launching from a terminated state. As a consequence of didReceiveIncomingPushWithPayload() not getting called, the app isn't calling reportNewIncomingCallWithUUID() and so after a few runs the OS stops launching the app entirely saying: "Application will not be launched because it failed to report an incoming call too many times". When didFinishLaunchingWithOptions() is called the launchOptions are nil, i.e. there is no way to distinguish the app from being launched as a consequence of reportNewIncomingVoIPPushPayload()(*) being called and therefore it is not possible to call reportNewIncomingCallWithUUID(). So this feature is totally broken apparently from previous behavior. Any comment? TIA (*)Well actually, the extension could write a flag to a shared group and the app read that on launch, but what a hack, and should be unnecessary.
1
0
734
Aug ’23
Push token change on app upgrade
Our app has some Crashlytics & Localytics reporting to collect metrics for diagnostic and info gathering. One thing I'm noticing recently is that if a user has version m of the app installed and updates to version m+1, then for some users, the app has detected and reported that the push token obtained with version m+1 is different from that of version m (for the same handset). That's fine - if the app has detected the change to the token it can send the new one to the server so the server can update. But my question is - if the user didn't explicitly launch the app and thus present the app with the chance to send the new token to the server, then what will happen to the pushes sent by the server using the old token? Presumably they won't get delivered if the token has changed, but if the user has no need to launch the app then they're never going to receive any pushes from the server until they do launch the app. However there's not necessarily any reason why a user should repeatedly launch an app once it's been set up (depending upon what it does and how it delivers info to the user and how the user interacts with it, there's no reason why a user should have to launch the app after initial installation and launch). If so then this seems like a gap in the design of push notifications? If they can change on the same handset, or another scenario is the user backs up their device to iCloud and then restores to a different handset, then in that case the push tokens will have definitely changed, yet any apps using push don't get the chance to send the new token to the server until the user launches the app, meanwhile all pushes from the server will be dropped.
1
0
983
Sep ’23
Is there a way of accessing/viewing files in an iOS app's shared group location from a Mac?
My goal is to try and get a unified logging system set up where logging from an iOS app and its extensions (primarily a notification service extension) get written into one central repository. So I was planning on setting up CocoaLumberjack in the app and the extension to use the same file path/name, adding the group capability to the app and the extensions and specifying the shared group directory as the file path. By default, for an app, CocoaLumberjack writes its files to: var/mobile/Containers/Data/Application/05464D4A-20F6-4E1F-9DBC-3109C053A1E8/Library/Caches/Logs/ On a Mac using an application such as iExplorer the above file and be located and viewed and copied etc. For an extension, it writes them to: /var/mobile/Containers/Data/PluginKitPlugin/5542F5EA-EB3A-4728-B33E-4E57C1B7B3B4/Library/Caches/Logs/ Now if I configure Cocoalumberjack to instead write the logger file to the shared group directory, then that will be at: /private/var/mobile/Containers/Shared/AppGroup/6CD5AF2C-54C9-46EF-B831-997B1DD6664F/ However its not possible using iExplorer to access this location. Using a Mac connected to the iPhone, is there an app or tool etc., that will enable me to locate the log file if it's created in the above AppGroup location?
1
0
1k
Sep ’23
How to reset Keychain "certificate is not trusted" error caused by VPN, without rebooting?
If I turn on (my company supplied VPN access) and then attempt to build with Xcode then that has the consequence that all the dev/distribution certificates in the keychain turn red and say "certificate is not trusted". Turning off VPN doesn't reset them back and of course re-attempting to build will fail. However if I reboot my MacBook, then the keychain is back in a good state again. However as I work remotely I constantly have to flick VPN on and off throughout the day, and having to reboot endlessly is a pain. Is there something I can do to reset the Keychain's certs to a good state without having to reboot? (and without having to delete them all and re-add them all back to the keychain).
1
0
668
Sep ’23