Hi folks,
I have trouble with reading NFC tag in background while my application is running.
I still receives a message in my iPhone 13, NFC tag of web Open "donator.cz" in application Safari.
But I would like to open the app Donator which is here: https://apps.apple.com/dk/app/don%C3%A1tor/id6473955033
My NFC chip scanned by "NFC Tools" is ISO 14443-3A (NXP-NTAG213)
In the tag is mentioned https://donator.cz/<8digits-number>**text
In my Info.plist of application is:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https://donator.cz</string>
</array>
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
<string>12FC</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>D2760000850101</string>
</array>
Apple CDN looks like: https://app-site-association.cdn-apple.com/a/v1/donator.cz
I have read in Apple documentation https://developer.apple.com/documentation/corenfc/adding-support-for-background-tag-reading
that application should be in progress A Core NFC reader session is in progress.
How to do it in AppDelegate or SceneDelegate.
One note is that everything works properly in case of reading NFC based on button click is pressed.
My NFCHandler looks like:
//
// NFCReader.swift
// Donator
//
// Created by Petr Hracek on 22.11.2024.
//
import Foundation
import UIKit
import CoreNFC
class NFCHandler: NSObject, NFCNDEFReaderSessionDelegate {
var readerSession: NFCNDEFReaderSession?
func startBackgroundScanning() {
guard NFCNDEFReaderSession.readingAvailable else {
return
}
readerSession = NFCNDEFReaderSession(delegate: self, queue: DispatchQueue.main, invalidateAfterFirstRead: true)
readerSession?.alertMessage = "Prilozte NFC tag"
readerSession?.begin()
}
func readTag(session: NFCNDEFReaderSession , tags: [NFCNDEFTag] ) {
if tags.count > 1 {
// Restart polling in 500ms
let retryInterval = DispatchTimeInterval.milliseconds(500)
session.alertMessage = "More than 1 tag is detected, please remove all tags and try again."
DispatchQueue.global().asyncAfter(deadline: .now() + retryInterval, execute: {
session.restartPolling()
})
return
}
// Connect to the found tag and perform NDEF message reading
let tag = tags.first!
session.connect(to: tag, completionHandler: { (error: Error?) in
if nil != error {
session.alertMessage = "Unable to connect to tag."
session.invalidate()
return
}
tag.queryNDEFStatus(completionHandler: { (ndefStatus: NFCNDEFStatus, capacity: Int, error: Error?) in
if .notSupported == ndefStatus {
session.alertMessage = "Tag is not NDEF compliant"
session.invalidate()
return
} else if nil != error {
session.alertMessage = "Unable to query NDEF status of tag"
session.invalidate()
return
}
tag.readNDEF(completionHandler: { (message: NFCNDEFMessage?, error: Error?) in
var statusMessage: String
if nil != error || nil == message {
statusMessage = "Fail to read NDEF from tag"
} else {
statusMessage = "Found 1 NDEF message"
DispatchQueue.main.async {
// Process detected NFCNDEFMessage objects.
debugPrint(message!)
//self.tableView.reloadData()
}
}
session.alertMessage = statusMessage
session.invalidate()
})
})
})
}
/// - Tag: sessionBecomeActive
/// This method will called when NFC session become active
/// Tells the delegate that the session detected NFC tags with NDEF messages.
func readerSessionDidBecomeActive(_ session: NFCNDEFReaderSession) {
debugPrint("NFC session become active======")
}
func readerSessionDidInvalidate(_ session: NFCNDEFReaderSession) {
debugPrint("NFC session invalidate======")
}
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(error)
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
for message in messages {
for record in message.records {
print("Type name format: \(record.typeNameFormat)")
print("Payload: \(record.payload)")
print("Type: \(record.type)")
print("Identifier: \(record.identifier)")
}
}
}
/// - Tag: processingNDEFTag
/// if This method is not implement then only func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) will call
/// Tells the delegate that the session detected NFC tags with NDEF messages and enables read-write capability for the session.
func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) {
self.readTag(session: session, tags: tags)
}
}
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
Just downloaded the new IOS18 update. immediately ran into problems.
in particular the new Photo app is dreadful. It is cumbersome to navigate, quite unintuitive to use and, frankly, a mess. I cannot imagine why Apple thought this an improvement compared to the simpler and much more usable previous version.
other problems include difficulties with location and home screens on the weather app, and others.
i was about to upgrade my iPhone (XR) to the iPhone 16. I am now seriously questioning the sense of that given how cumbersome many of the apps have become.
Topic:
App & System Services
SubTopic:
General
I am implementing a couple custom intents in my app. Having completed the implementation of the custom intent definitions and the intent handlers which presumably should be called on voice command based on the suggestedInovocationPhrase, I am getting stumped with just getting IOS to recognize my shortcut donation. While the shortcut donation is executed multiple times from the view that I am trying to create the shortcut for, it is never being displayed in the shortcut app or on my lock screen as having been donated. In my settings App, I have turned on (under Developer) "Display Recent Shortcuts" and "Display Donations on Lock Screen". Here is the code that is executing each time I think I am making a donation:
- (NSUserActivity *) CreateMyShortcut {
NSUserActivity *newActivity = [[NSUserActivity alloc] initWithActivityType: kMyShortCutActivityType];
if (@available(iOS 12.0, *)) {
newActivity.persistentIdentifier = kMyShortCutActivityType;
newActivity.eligibleForSearch = TRUE;
newActivity.eligibleForPrediction = TRUE;
CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithContentType: UTTypeImage];
newActivity.title = @"My Shortcut";
attributeSet.contentDescription = @"description";
newActivity.suggestedInvocationPhrase = @"Create Widget";
UIImage *image = [UIImage imageNamed:@"MyApp_Icon.jpg"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
attributeSet.thumbnailData = imageData;
newActivity.contentAttributeSet = attributeSet;
}
return newActivity;
}
This is called from the view that I want to create the shortcut for with the following code:
// Donate a shortcut to allow Siri to assist with creating a parts list
NSUserActivity *activity = [[MyDonationManager sharedInstance] CreateMyShortcut];
NSLog(@"Donating Siri Shortcut");
[activity becomeCurrent];
Is there something else I need to do?
Does anyone know?
Callerid name is not being updated in device recent calls when incoming call is received or outgoing call is initiated for a number stored in my app unless phone app is force quit and relaunched. Is there any way to sync or refresh the callerid to be displayed in recent calls even if phone app is in background ?
Topic:
App & System Services
SubTopic:
General
There is a bug when try to open the push notification of appintent at the lock screen.
I'm developing a Raycast extension that using Apple MusicKit API, is it safe to store developer tokens in Raycast extensions?
On iOS Bundle.main.preferredLocalizations returns the list of languages the application bundle supports in user-preferred order with the first element being the language the application is running in.
Additionally Locale.preferredLanguages returns the list of languages in the order they are presented in Preferences.app > General > Language & Region > Preferred Languages with the first element being the user's "primary language" (i.e. the language the system is running in).
However this only seems to be true unless the user has chosen a per-app language which is different from the primary language in which case Locale.preferredLanguages.first is equal to Bundle.main.preferredLocalizations.first - regardless of the latter's position in the Preferred Languages list.
Furthermore this seems to change depending on the value of the "AppleLanguages" key in the User Defaults' global domain (see c.f. https://stackoverflow.com/a/42648166).
Is this behaviour documented anywhere?
Addendum: I know that according to https://forums.developer.apple.com/forums/thread/718512?answerId=733680022#733680022
AppleLanguages is an implementation detail, not something that’s considered API.
Locale.preferredLanguages is API, though.
A user gave me the crash log on his M4 machine when he first launches the app. I have M1 and my app works fine, which begs the question, why M4 has the crash! This is my app the I developed since 2011 until now.
Any hints will be appreciated or anyone has similar issues like to share?
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: DA1CEECB-28D4-40A9-8F0C-7125812084F4
CrashReporter Key: FB8A5DBB-7140-D370-AC72-EC158266383C
Hardware Model: Mac16,3
Process: Stocks Live [5506]
Path: /private/var/folders/*/Stocks Live.app/Stocks Live
Identifier: com.cinnamonmobile.StocksLive
Version: 34.2 (34.2.0)
AppStoreTools: 16B39
AppVariant: 1:MacFamily20,1:18
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.cinnamonmobile.StocksLive [2018]
Date/Time: 2024-11-27 12:41:48.0456 -0500
Launch Time: 2024-11-27 12:41:47.5710 -0500
OS Version: macOS 15.1.1 (24B2091)
Release Type: User
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_MEMORY_ERROR at 0x0000000120034000
Exception Codes: 0x000000000000000a, 0x0000000120034000
VM Region Info: 0x120034000 is in 0x120034000-0x120038000; bytes after start: 0 bytes before end: 16383
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
CoreAnimation 120030000-120034000 [ 16K] rw-/rwx SM=PRV
---> mapped file 120034000-120038000 [ 16K] r--/rw- SM=COW Object_id=14630bfe
CoreAnimation 120038000-12003c000 [ 16K] r--/r-- SM=PRV
Termination Reason: SIGNAL 10 Bus error: 10
Terminating Process: exc handler [5506]
Triggered by Thread: 0
Kernel Triage:
decmpfs - (arg = 0x80000001) compressor is not registered
APFS - (arg = 0x200040) Pagein of compressed inode failed
VM - (arg = 0x190000002d) Filesystem pagein returned an error in vnode_pagein
VM - (arg = 0x0) Page has error bit set
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 CoreFoundation 0x18803f48c __CFStringCreateImmutableFunnel3 + 716
1 FincancialCoreFrameWork 0x10358d3c4 -[MOStringDocument loadFromContents:ofType:error:] + 156
2 UIKitCore 0x1ba34a67c __32-[UIDocument readFromURL:error:]_block_invoke + 104
3 libdispatch.dylib 0x187e20658 _dispatch_client_callout + 20
4 libdispatch.dylib 0x187e2fdb0 _dispatch_async_and_wait_invoke + 92
5 libdispatch.dylib 0x187e20658 _dispatch_client_callout + 20
6 libdispatch.dylib 0x187e2ef68 _dispatch_main_queue_drain + 980
7 libdispatch.dylib 0x187e2eb84 _dispatch_main_queue_callback_4CF + 44
8 CoreFoundation 0x1880f8e60 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
9 CoreFoundation 0x1880b8a4c __CFRunLoopRun + 1996
10 CoreFoundation 0x1880b7bc4 CFRunLoopRunSpecific + 588
11 HIToolbox 0x193529f64 RunCurrentEventLoopInMode + 292
12 HIToolbox 0x19352fd54 ReceiveNextEventCommon + 636
13 HIToolbox 0x19352feb8 _BlockUntilNextEventMatchingListInModeWithFilter + 76
14 AppKit 0x18bbe398c _DPSNextEvent + 660
15 AppKit 0x18c523ddc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
16 AppKit 0x18bbd6a64 -[NSApplication run] + 480
17 AppKit 0x18bbad2e8 NSApplicationMain + 888
18 AppKit 0x18bdfb7f4 _NSApplicationMainWithInfoDictionary + 24
19 UIKitMacHelper 0x1a28f8b38 UINSApplicationMain + 972
20 UIKitCore 0x1b99de3a8 UIApplicationMain + 148
21 Stocks Live 0x102bcc058 0x102bc4000 + 32856
22 dyld 0x187c50274 start + 2840
Thread 1:: Dispatch queue: UIDocument File Access
0 libsystem_kernel.dylib 0x187f93b8c __ulock_wait + 8
1 libdispatch.dylib 0x187e21048 _dlock_wait + 56
2 libdispatch.dylib 0x187e20dfc _dispatch_thread_event_wait_slow + 56
3 libdispatch.dylib 0x187e2ffc4 __DISPATCH_WAIT_FOR_QUEUE__ + 368
4 libdispatch.dylib 0x187e2fb70 _dispatch_sync_f_slow + 148
5 UIKitCore 0x1ba351384 -[UIDocument(UIDocumentInternal) _performBlock:synchronouslyOnQueue:] + 76
6 UIKitCore 0x1ba347ff0 __40-[UIDocument openWithCompletionHandler:]_block_invoke + 588
7 libdispatch.dylib 0x187e1e8f8 _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x187e20658 _dispatch_client_callout + 20
9 libdispatch.dylib 0x187e27c60 _dispatch_lane_serial_drain + 744
10 libdispatch.dylib 0x187e28768 _dispatch_lane_invoke + 380
11 libdispatch.dylib 0x187e337e8 _dispatch_root_queue_drain_deferred_wlh + 288
12 libdispatch.dylib 0x187e33034 _dispatch_workloop_worker_thread + 540
13 libsystem_pthread.dylib 0x187fcf3d8 _pthread_wqthread + 288
14 libsystem_pthread.dylib 0x187fce0f0 start_wqthread + 8
Thread 2:
0 libsystem_pthread.dylib 0x187fce0e8 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x187fce0e8 start_wqthread + 0
A Mac Catalyst App Creates an AppKit Bundle Plugin in which @available does not work。
In AppKit Bundle Plugin, there is not watchOS and iOS version can not be higher than 28, but the log has been output.
if (@available(watchOS 18.0, *)) {
NSLog(@"bundle is available watchOS");
}
if (@available(iOS 28.0, *)) {
NSLog(@"bundle is available iOS");
}
demo link: https://pan.baidu.com/s/1s_5qmsL6Bh-df3A1PfD0OA
Extracted code: 5ndj
Imagine we have an Xcode workspace containing two projects:
MyLibrary.xcodeproj holding a framework target
MyShortcutsApp.xcodeproj holding an app target which consumes MyLibrary framework
Both targets define App Intents and the ones from MyLibrary are exposed via AppIntentsPackage accordingly.
When trying to wrap the App Intent from framework as App Shortcut and passing localized AppShortcutPhrases I do see the following compile error:
".../Resources/de.lproj/AppShortcuts.strings:11:1: error: This AppShortcut does not map to a known action (MyLibraryIntent specified). (in target 'MyShortcutsApp' from project 'MyShortcutsApp')"
If I use the same localized App Shortcut phrases for an App Intent which is locally defined in the app target, everything works fine and also if I use the framework-provided App Intent in and App Shortcut without passing any localized phrases.
This is happening with Xcode 16.0 (16A242d), with 16.1 (16B40) and with 16.2 beta 2 (16C5013f).
I already raised this issue via FB15701779 which contains a sample project to reproduce and to further analyze the issue.
Thanks for any hint on how to solve that.
Frank
The app gets stuck after login on an iOS 18 device. It works in Xcode, but the simulator shows the following console error: IntegrationApp(769,0x1f0094c00) malloc: xzm: failed to initialize deferred reclamation buffer (46).
I want to understand how it manages memory allocation if i need more memory later than the memory i specified during initialisation . Does it allocates new chunk of memory and dellocate older memory or does it already allocated more memory than i asked for in first place? Just want to understand how exactly this calculation is done ?
And i do initialisation of NSMutableString in swift , will these same principle of expension applied there ?
Hi,
I have been successful at writing Swift code using a NWListener to listen to WebSocket connections on a specific port, but I do not seem to be able to get the path from the URL for creating different types of connections.
For instance, differentiating between ws://127.0.0.1:80/updates and ws://127.0.0.1:80/changes.
I'd like to be able to get the "updates" or "changes" part when I receive the new connection notification.
Having more sample code around WebSockets and how the upgrade process works that would also be great.
Thank you !
Daniel Tapie
Crash occurs in @MainActor class or function in iOS 14
Apps built and distributed targeting Xcode 16 version swift6 crash on iOS 14 devices.
We create a static library and put it in our app's library.
Crash occurs in all classes or functions of the static library (@MainActor in front).
It does not occur from iOS / iPadOS 15.
If you change the minimum supported version of the static library to iOS 11, a crash occurs, and if you change it to iOS 14, a crash does not occur.
Is there a way to keep the minimum version of the static library at iOS 11 and prevent crashes?
PLATFORM AND VERSION
Xcode Version 16.2 beta 3 (16C5023f)
macOS 15.1.1 (24B91)
Run-time configuration: iOS 18.0
DESCRIPTION OF PROBLEM
We are currently testing the functionality of AirDrop by bringing iPhones close to each other.
I am trying to transfer the activityItemsConfiguration set in the modal screen via AirDrop.
However, if presentationStyle is fullscreen, it succeeds, but otherwise the connection is successful but no item is displayed on the screen.
STEPS TO REPRODUCE
Open my project.
Run on device
Tap Present with toggle is off.
ModalViewController presented as sheet.
Bring another iPhone closer
Play connection animation, then just display connected.
I work on a macOS application that functions as a daemon. To test it, I:
Compile executables.
Use pkgbuild and productbuild to build an application bundle.
Use codesign and notarytool to sign and notarize the app.
Install the app with /usr/sbin/installer -target LocalSystem -pkg .... This often overwrites the previous version of the app.
Sometimes, the installation fails at the postinstall stage, when it can not find the application's install directory. We explicitly check for this error in our script:
if ! [ -d "$APP_INSTALL_DIR"/Contents ]; then
echo "directory ${APP_INSTALL_DIR}/Contents is missing"
exit 1
fi
This is unexpected!
Even worse, some of our customers have occasionally seen the same issue!
We use a postinstall script in order to install files into the /Library/LaunchDaemons and /Library/ LaunchAgents directories, and start the agent with launchctl bootstrap.
Our preinstall script makes sure that the previous version of our application is fully uninstalled (so there is no confusion), and we wonder if that is part of the problem.
While researching this error, I ran across a discussion of a similar issue on Stackoverflow: <https:// stackoverflow.com/questions/19283889>. One of the commenters there wrote:
It appears that the OS X installer uses information about already installed packages and application bundles in order to decide where and if to install new packages. As a result, sometimes my installer did not install any files whatsoever, and sometimes it just overwrote the .app bundle in my build tree. Not necessarily the one used to build the installer, but any .app bundle that OS X had found. In order to get the installer to install the files properly I had to do two things:
Tell OS X to forget about the installed package. sudo pkgutil --forget <package id> Not sure if this is needed for you nor in my case, but it is probably a good idea anyway.
Delete all existing .app bundles for the app. If I didn't do this, the existing app bundle was overwritten on install instead of the app being placed in /Applications. Maybe there is a way to prevent this while building the installer package, but I haven't found it.
On the other hand, the man page for pkgutil says not to use --forget from an installer:
Discard all receipt data about package-id, but do not touch the installed files. DO NOT use this command from an installer package script to fix broken package design.
What is the correct approach to fix this problem?
Topic:
App & System Services
SubTopic:
General
Hello!
I'm trying to donate an Intent to iOS using IntentDonationManager, following the methods described in the documentaion.
try await IntentDonationManager.shared.donate(intent: MyIntent()) // succeeded
However, I'm not seeing any effect of this action anywhere in the system (iOS 17 and 16). I have debugged it on both the simulator and a physical device, and I have also enabled the "Display Recent Shortcuts" toggle in the developer settings, but I still don't see any relevant suggestions appearing.
Similarly, the issue also occurs with the old SiriKit framework, where INInteraction.donate(completion:) doesn't seem to have any observable effect. I recall that in iOS 15, the simulator would immediately present the donated Shortcut action on the lock screen and Spotlight page. However, starting from iOS 16 and continuing to the current iOS 17 beta 1/2, I haven't been able to achieve the same behavior using the same code.
Another similar report: https://developer.apple.com/forums/thread/723109
So is there any way to test or verify the results of this donation action?
Hello,
I’ve implemented a feature in my app using AppIntent. When the app is not running in the background and is launched for the first time via a shortcut, both application:didFinishLaunchingWithOptions: and applicationWillEnterForeground: are called.
Normally, on the first launch, applicationWillEnterForeground: is not invoked. However, this behavior seems to occur only when the app is launched through a shortcut.
I’d like to understand why applicationWillEnterForeground: is being called in this scenario.
For reference, the AppIntent has openAppWhenRun set to true.
Thank you in advance for your help!
Hello,
I have a question related to the public iTunes Search API: https://performance-partners.apple.com/search-api
Do all the books have an ISBN associated? I used to do queries like:
https://itunes.apple.com/lookup?isbn=9781501110368. That book is available on Apple Books here: https://books.apple.com/us/book/it-ends-with-us/id1052928247 and the endpoint above returns informations about it.
However for newer books like:
https://itunes.apple.com/lookup?isbn=9781419766954
https://itunes.apple.com/lookup?isbn=9781250288776
Nothing comes back anymore even if those books exist there. The url's for the 2 above are:
https://books.apple.com/us/book/hot-mess-diary-of-a-wimpy-kid-19/id6476554491
https://books.apple.com/mt/book/the-mirror/id6474420363
For newer books starting the beginning of September 2024, nothing seems to come back when you search them by ISBN.
Thanks