Is it possible to write an iOS app or app extension to block an incoming call based on the area code (or some other portion of the incoming call number)?
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
On iOS:When one receives a file of type .pages by email, Mail displays a large Pages icon and tapping on it opens Pages. (A long-press brings up the more complicated Actions screen).When one receives a file of type .vcf by email, Mail displays a large Contacts icon and tapping on it opens Contacts. (A long-press brings up the more complicated Actions screen).I have my own custom file type, .ripf, and I want to have the same behaviour because that is what my users will expect. Accordingly, in my app's Info.plist I have a CFBundleDocumentTypes dictionary providing a one-element LSItemContentTypes array referring to the name 'com.universalis.ripcard', and a UTExportedTypeDeclarations dictionary associating the UTTypeIdentifier 'com.universalis.ripcard' with a public.filename-extension 'ripf' and a public.mime-type 'text/vnd.universalis.ripcard'. All the other entries in those two dictionaries are present and correct as far as I can tell. Both CFBundleDocumentTypes[0].CFBundleTypeIconFiles and UTExportedTypeDeclarations[0].UTTypeIconFiles contain a list of icon files for the file type.(That rather long paragraph is to avoid boring people by including the entire Info.plist!)Some things do work..ripf files received via AirDrop bring up a suitable "Open with..." message which mentions my app, and tapping the message opens the app..ripf files received as an email attachment display as an icon. But it is the app's icon and not the icon of the file type.BUTTapping on a received file's icon does not open the app, but only opens the generic Actions screen, offering Message, Mail, WhatsApp, Notes, and only then (after the user has scrolled sideways) "Copy to..." my app.Now, the whole apparatus of CFBundleDocumentTypes and UTExportedTypeDeclarations is obscure and under-documented, and indeed the main documenation for the latter has a big warning at the top saying that it is obsolete and not being updated. That doesn't matter so much. What I need to know is:(Less important): How do I get the right file icon?(More important): How do I get my app to open when the icon is tapped, as Pages and Contacts do? There must be a way – unless special cases for those two apps are wired into iOS itself.
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
I am trying to follow the guidance for testing a Local Experience, as listed in the Testing Your App Clip’s Launch Experience - https://developer.apple.com/documentation/app_clips/testing_your_app_clip_s_launch_experience documentation. I have successfully created my App Clip target, and can confirm that running the App Clip on my device does launch the App Clip app as I expected. Further, I can successfully test the App Clip on device, by setting the _XCAppClipURL argument in the App Clip's scheme.
I would like to test a Local Experience. The documentation states that for testing Local Experiences;
To test your app clip’s invocation with a local experience, you don’t need to add the Associated Domains Entitlement, make changes to the Apple App Site Association file on your web server, or create an app clip experience for testing in TestFlight. Therefore, I should be able to configure a Local Experience with any desired domain in Settings -> Developer -> Local Experience, generate a QR code or NFC tag with that same URL, and the App Clip experience should appear. I have taken the following steps;
Built and run my App Clip on my local device.
In Settings -> Developer -> Local Experience, I have registered a new experience using a URL prefix https://somewebsite.com
Set my Bundle ID to com.mycompany.myapp.Clip, which exactly matches the Bundle Identifier, as listed in Xcode, under my App Clip target.
Generated a QR code which directs me to https://somewebsite.com
In theory, I believe I should be able to open the Camera app on my device, point the camera at the QR code, and the App Clip experience should appear. However, I received mixed experiences. 50% of the time, I receive a pop-up directing me to open https://somewebsite.com in Safari, the other 50% of the time, no banner or action occurs whatsoever.
Is this an issue anyone has faced before, or have I pursued these steps out of order?
i thought it is impossible to have CallKit show system UI for outgoing calls. but then i saw this:
"For incoming and outgoing calls, CallKit displays the same interfaces as the Phone app..."
https://developer.apple.com/documentation/callkit
how do i present it though? or is this a documentation error?
Hi, I have pretty trivial problem. So, I am trying to use URLSession network request but I am getting errors.
This code is in the shared file that works when I run it as app, but when I run it as AppClip it is not working. Running on the simulator is working even as AppClip.
Here is the code (pretty trivial):
let session = URLSession.shared
let url = URL(string: "https://learnappmaking.com/ex/users.json")!
let task = session.dataTask(with: url, completionHandler: { _, response, error in
print(error)
print(response)
})
task.resume()
I am getting this error:
2020-11-20 19:35:05.189273+0100 ExampleAppClip[14703:4633304] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 92 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 92 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2020-11-20 19:35:05.363730+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.1:3] connectx(8 (guarded), [srcif=0, srcaddr=<NULL>, dstaddr=104.27.132.57:443], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [65: No route to host]
2020-11-20 19:35:05.364100+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.1:3] connectx failed (fd 8) [65: No route to host]
2020-11-20 19:35:05.364195+0100 ExampleAppClip[14703:4633299] [] nw_socket_connect connectx failed [65: No route to host]
2020-11-20 19:35:05.368229+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.2:3] connectx(8 (guarded), [srcif=0, srcaddr=<NULL>, dstaddr=104.27.133.57:443], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [65: No route to host]
2020-11-20 19:35:05.368424+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.2:3] connectx failed (fd 8) [65: No route to host]
2020-11-20 19:35:05.368484+0100 ExampleAppClip[14703:4633299] [] nw_socket_connect connectx failed [65: No route to host]
2020-11-20 19:35:05.370781+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.3:3] connectx(8 (guarded), [srcif=0, srcaddr=<NULL>, dstaddr=172.67.210.249:443], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [65: No route to host]
2020-11-20 19:35:05.370989+0100 ExampleAppClip[14703:4633299] [connection] nw_socket_connect [C1.3:3] connectx failed (fd 8) [65: No route to host]
2020-11-20 19:35:05.371054+0100 ExampleAppClip[14703:4633299] [] nw_socket_connect connectx failed [65: No route to host]
2020-11-20 19:35:05.372142+0100 ExampleAppClip[14703:4633299] Connection 1: received failure notification
2020-11-20 19:35:05.372241+0100 ExampleAppClip[14703:4633299] Connection 1: failed to connect 1:65, reason -1
2020-11-20 19:35:05.372291+0100 ExampleAppClip[14703:4633299] Connection 1: encountered error(1:65)
2020-11-20 19:35:05.374764+0100 ExampleAppClip[14703:4633300] Task <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:65])
2020-11-20 19:35:05.383016+0100 ExampleAppClip[14703:4633299] Task <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=65, NSUnderlyingError=0x282ecc5a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=65, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
&#9;&#9;"LocalDataTask <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://learnappmaking.com/ex/users.json, NSErrorFailingURLKey=https://learnappmaking.com/ex/users.json, _kCFStreamErrorDomainKey=1}
Optional(Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=65, NSUnderlyingError=0x282ecc5a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=65, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
&#9;&#9;"LocalDataTask <3C72DFED-F839-4BD2-9FE2-CC0B8BB7090F>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://learnappmaking.com/ex/users.json, NSErrorFailingURLKey=https://learnappmaking.com/ex/users.json, _kCFStreamErrorDomainKey=1})
nil
There are use cases where someone who's using an Apple Pencil may not want to enter text via Scribble. A simple example is writing "UIViewController" in a text view is unlikely to be successful.
I'd like to disable Scribble in this case and let the keyboard become the input mechanism. (Disabling Scribble system-wide in Settings is both cumbersome and overkill.)
The closest I can come to making this happen is by adding a UIScribbleInteraction on a UITextView and returning false when scribbleInteraction(shouldBeginAt:) is called.
This disables Scribble on the text view, and prevents writing from being converted into text, but the input widget still appears on screen and isn't very useful.
Here is a sample project that demonstrates the problem:
http://files.iconfactory.net/craig/bugs/Scribbler.zip
Hopefully, I'm doing something wrong here. If not, I'm happy to submit this as a FB.
-ch
Our app's widget often doesn't show up in the "Widget Gallery".
Lots of our users complain about this issue.
They can't see the widget in widget gallery after opening the app.
In some cases, the widget does not appear in the widget gallery even after turning the phone off and on.
I saw in another question that this is a bug.
This bug will be fixed someday, but is there anything we can do before that?
I have an app developed by using the Callkit/Call-Blocking and received feedback from individual users, when using [cxcalldirectorymanager reloadextensionwithidentifier] to write call blocking data, it returned error code 11 with the following contents:
errorCode: 11
errorDomain: com.apple.callkit.database.sqlite
errorDescription: sqlite3_step for query 'DELETE FROM PhoneNumberBlockingEntry WHERE extension_id =?' returned 11 (11) errorMessage 'database disk image is malformed'
I want to know the reasons for this error and how to solve it,Thanks!
Is there any resource which describes this type of errors?
I was integrating SKADNetwork view through Ad attribution and everything from the source app side is done and this error
appears after the target app is installed and opened.
Here is the full error
Error setting install attribution pingback registered for app: <APP ID>, error: Error Domain=ASDErrorDomain Code=1209 "SKAdNetwork: Could not set registered for pingback that does not exist." UserInfo={NSLocalizedDescription=SKAdNetwork: Could not set registered for pingback that does not exist.}, result: 0
I cannot find any resource on the internet which gives any info about this ASDErrors.
If anyone can help, you would be doing me a solid, Thanks in advance.
IMPORTANT Rather than use the code below, I recommend that you adopt Swift’s shiny-new Subprocess package. That’s what I’m doing! (-:
Running a child process using Process (or NSTask in Objective-C) is easy, but piping data to and from the child’s stdin and stdout is surprisingly tricky. I regularly see folks confused by this. Moreover, it’s easy to come up with a solution that works most of the time, but suffers from weird problems that only show up in the field [1].
I recently had a couple of DTS incidents from folks struggling with this, so I sat down and worked through the details. Pasted below is the results of that effort, namely, a single function that will start a child process, pass it some data on stdin, read the data from the child’s stdout, and call a completion handler when everything is done.
There are some things to note here, some obvious, some not so much:
I’ve included Swift and Objective-C versions of the code. Both versions work the same way. The Swift version has all the comments. If you decide to base your code on the Objective-C version, copy the comments from there.
I didn’t bother collecting stderr. That’s not necessary in many cases and, if you need it, it’s not hard to extend the code to handle that case.
I use Dispatch I/O rather than FileHandle to manage the I/O channels. Dispatch I/O is well suited to this task. In contrast, FileHandle has numerous problems working with pipes. For the details, see Whither FileHandle?.
This single function is way longer than I’d normally tolerate. This is partly due to the extensive comments and party due to my desire to maintain focus. When wrapping Process it’s very easy to run afoul of architecture astronaut-ism. Indeed, I have a much more full-featured Process wrapper sitting on my hard disk, but that’s going to stay there in favour of this approach (-:
Handling a child process correctly involves some gnarly race conditions. The code has extensive comments explaining how I deal with those.
If you have any questions or comments about this, put them in a new thread. Make sure to tag that thread with Foundation and Inter-process communication so that I see it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Indeed, this post shows that I’ve made this sort of mistake myself )-:
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?
I have received two strange crash reports from an iPad11,7 running iPadOS 15.1 and an iPad11,2 running iPadOS 15.2.
On both occasions, the crashed thread calls CFURLRequestSetMainDocumentURL, which in turn calls _dispatch_source_set_runloop_timer_4CF in libdispatch, after which the application crashes with SIGSEGV and SEGV_MAPERR.
The crashed thread's call stack is displayed below. Full crash logs are attached as well. What could this be?
Exception Type: SIGSEGV
Exception Codes: SEGV_MAPERR at 0x21d
Crashed Thread: 20
Thread 20 Crashed:
0 libdispatch.dylib 0x00000001829e1784 _dispatch_source_set_runloop_timer_4CF + 36
1 CFNetwork 0x00000001834fc824 CFURLRequestSetMainDocumentURL + 2240
2 CFNetwork 0x00000001836b89a8 _CFNetworkErrorGetLocalizedDescription + 693652
3 CFNetwork 0x00000001834fdb1c CFURLRequestSetMainDocumentURL + 7096
4 CFNetwork 0x00000001834f3c34 CFURLRequestSetURL + 9668
5 libdispatch.dylib 0x00000001829ca914 _dispatch_call_block_and_release + 28
6 libdispatch.dylib 0x00000001829cc660 _dispatch_client_callout + 16
7 libdispatch.dylib 0x00000001829d3de4 _dispatch_lane_serial_drain + 668
8 libdispatch.dylib 0x00000001829d498c _dispatch_lane_invoke + 440
9 libdispatch.dylib 0x00000001829d5c74 _dispatch_workloop_invoke + 1792
10 libdispatch.dylib 0x00000001829df1a8 _dispatch_workloop_worker_thread + 652
11 libsystem_pthread.dylib 0x00000001f1eea0f4 _pthread_wqthread + 284
12 libsystem_pthread.dylib 0x00000001f1ee9e94 start_wqthread + 4
second_crashlog.txt
report-2517628380750009999-e4d7ea06-6f22-4b7e-b129-045599e1dee5.txt
Hello, sometimes if I use NSMetadataQuery to obervse my file changes on macOS, it crash for this reason, its odd and i have no clue for this problem becuse in my code I never get results using index, anyone help? thanks!
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSMetadataQueryResultArray objectAtIndex:]: index (251625) out of bounds (251625)'
terminating with uncaught exception of type NSException
abort() called
I was playing around a bit with the new AttributedString and a few questions came up.
I saw this other forum question "JSON encoding of AttributedString with custom attributes", but I did not completely understand the answer and how I would need to use it.
I created my custom attribute where I just want to store additional text like this:
enum AdditionalTextAttribute: CodableAttributedStringKey, MarkdownDecodableAttributedStringKey {
typealias Value = AttributedString
static let name = "additionalText"
}
I then extended the AttributeScopes like this:
extension AttributeScopes {
struct MyAppAttributes: AttributeScope {
let additionalText: AdditionalTextAttribute
let swiftUI: SwiftUIAttributes
}
var myApp: MyAppAttributes.Type { MyAppAttributes.self }
}
and I also implemented the AttributeDynamicLookup like this:
extension AttributeDynamicLookup {
subscript<T: AttributedStringKey>(dynamicMember keyPath: KeyPath<AttributeScopes.MyAppAttributes, T>) -> T { self[T.self] }
}
So next I created my AttributedString and added some attributes to it:
var attStr = AttributedString("Hello, here is some text.")
let range1 = attStr.range(of: "Hello")!
let range2 = attStr.range(of: "text")!
attStr[range1].additionalText = AttributedString("Hi")
attStr[range2].foregroundColor = .blue
attStr[range2].font = .caption2
Next I tried to create some JSON from my string and took a look at it like this:
let jsonData = try JSONEncoder().encode(attStr)
print(String(data: jsonData, encoding: .utf8) ?? "no data")
//print result: ["Hello",{},", here is some ",{},"text",{"SwiftUI.ForegroundColor":{},"SwiftUI.Font":{}},".",{}]
I guess it makes sense, that both SwiftUI.ForegroundColor and SwiftUI.Font are empty, because they both do not conform to Codable protocol.
My first question would be: Why does my additionalText attribute not show up here?
I next tried to extend Color to make it codable like this:
extension Color: Codable {
enum CodingKeys: CodingKey {
case red, green, blue, alpha
case desc
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
guard let cgColor = self.cgColor,
let components = cgColor.components else {
if description.isEmpty { throw CodingErrors.encoding }
try container.encode(description, forKey: .desc)
return
}
try container.encode(components[0], forKey: .red)
try container.encode(components[1], forKey: .green)
try container.encode(components[2], forKey: .blue)
try container.encode(components[3], forKey: .alpha)
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let description = try container.decodeIfPresent(String.self, forKey: .desc) {
if description == "blue" {
self = Color.blue
return
}
throw CodingErrors.decoding
}
let red = try container.decode(CGFloat.self, forKey: .red)
let green = try container.decode(CGFloat.self, forKey: .green)
let blue = try container.decode(CGFloat.self, forKey: .blue)
let alpha = try container.decode(CGFloat.self, forKey: .alpha)
self.init(CGColor(red: red, green: green, blue: blue, alpha: alpha))
}
}
But it looks like even though Color is now codable, the encoding function does not get called when I try to put my attributed string into the JSONEncoder.
So my next question is: Does it just not work? Or do I also miss something here?
Coming to my last question: If JSONEncoder does not work, how would I store an AttributedString to disk?
I am testing App Clip on Testflight to show App Clip Card but it only shows a white Card with the message: “This app clip is not currently available in your country or region” (if using Local Expreriences, it shows normally)
I have fully installed apple-app-site-association, App Clip Experience, Domain URL Status also validated ... don't understand why, is the app "Redy For Sale" new to show the Card?. I want to let customers test show App Clip Card without using Local Expreriences on Testflight
If anyone knows, please help, thank you.
I have two call directory extensions, each with InfoPlist.strings in en.lproj and nb.lproj directories. In these files I've defined CFBundleDisplayName for both locales.
These names are displayed under Settings -> Phone -> Call Blocking & Identification. On iOS 12.2 the names are displayed correctly in both Norwegian and English.
Testing on iOS 15.3 the English names are displayed even when device language is set to Norwegian.
Worth noting: When updating the English versions of CFBundleDisplayName this is immediately reflected in Call Blocking & Identification page with Norwegian device language.
As this feature requires a real device, I'm unable to test on iOS 13 and 14.
Hi,
I'm trying out the beta for music kit. In the current version of my app, my widget can show multiple albums. I preload the images of the album covers. In the beta's the url that is returned for the artwork starts with: "musickit://", which does not work with URLSession. How can I preload the data using the new url scheme?
Current code:
func fetchArtworkFor (musicID: MusicItemID, url : URL?) async throws -> UIImage? {
guard let url = url else {
return nil
}
let urlRequest = URLRequest (url: url)
let data = try await URLSession.shared.data(for: urlRequest)
let image = UIImage(data: data.0)
return image
}
// Some other function
for album in albumsToShow {
if let url = album.artwork?.url(width: context.family.imageHeight, height: context.family.imageHeight), let image = try? await fetchArtworkFor(musicID: album.id, url:url) {
images[album] = image
}
}
I'm trying to use ScreenCaptureKit on a Mac Catalyst app, on macOS 12.5.1.
I'm not sure if I'm doing something wrong, but it crashes as soon as I try to request SCShareableContent. It crashes on internal code, calling a method it can't find, which makes me think this is a bug in the framework rather than incorrect configuration.
Any hints on how to work around this problem?
The crash is:
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RPDaemonProxy fetchShareableContentWithOption:windowID:withCompletionHandler:]: unrecognized selector sent to instance 0x6000037d5dc0'
terminating with uncaught exception of type NSException
ScreenCaptureKit-Crash.txt
Topic:
App & System Services
SubTopic:
General
Tags:
Mac Catalyst
ReplayKit
ScreenCaptureKit
wwdc2022-10155
My app is mostly implemented in UIKit. Will AppIntents work with UIKit? If so, which (scene or app) delegate method gets called to start the intent?