Post

Replies

Boosts

Views

Activity

PHPickerViewController Disregards Order Photo is Selected
I use a PHPickerViewController for a user to select profile images. I want the order in which the photos were selected, respected. However, whenever I return the selected results, the order in which I selected is not reflected. I've double checked my config, but no solution has worked and would appreciate any guidance that does not involve using a 3rd party! Apple Documentation states simply setting the .selection property to .ordered should respect the user's selected order, but it does not!! documentation //Setup code var config = PHPickerConfiguration() config.selectionLimit = 3 config.filter = .images config.selection = .ordered let picker = PHPickerViewController(configuration: config) picker.delegate = self //Delegate handler func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { guard !results.isEmpty else { picker.dismiss(animated: true) return } self.photos = [] var tempImages: [Int: UIImage] = [:] let dispatchGroup = DispatchGroup() for (index, result) in results.enumerated() { dispatchGroup.enter() // Enter the group result.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] object, error in defer { dispatchGroup.leave() } guard let self = self else { return } if let image = object as? UIImage { tempImages[index] = image } } } dispatchGroup.notify(queue: .main) { [weak self] in guard let self = self else { return } for index in 0..<tempImages.keys.count { if let image = tempImages[index] { self.photos?.append(image) } } } picker.dismiss(animated: true) }
1
0
353
Feb ’24
UNNotificationServiceExtension Not Displaying Sender Image
I created a Notification Service Extension to display profile images in place for the app image (i.e. iMessage). I send a remote push notification via Firebase Functions, and in the payload, the relevant profile image url string. The profile image url string in the payload is successfully delivered as it appears in my console log and AppDelegate didReceiveRemoteNotification function. My problem is the profile image does not replace the default app icon image in the remote push notification. Below is my configuration. Any guidance would be appreciated! Main target app: the info plist contains NSUSerActivityTypes = [INSendMessageIntent]. The Communications Notifications capability is enabled and "Copy only when installing" in Build Phases Embed Foundation Extensions Notification Service Extension plist: contains NSExtension > NSExtensionAttributes > IntentsSupported > INSendMessageIntent. Notification Service Extension class code: var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent? override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { self.contentHandler = contentHandler bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) guard var bestAttemptContent = bestAttemptContent else { return } guard let fcmOptions = bestAttemptContent.userInfo["fcm_options"] as? [String: Any], let attachmentUrlAsString = fcmOptions["imageURL"] as? String else { contentHandler(bestAttemptContent) return } if let attachmentUrl = URL(string: attachmentUrlAsString) { var senderNameComponents = PersonNameComponents() senderNameComponents.nickname = bestAttemptContent.title let profileImage = INImage(url: attachmentUrl) let sender = INPerson(personHandle: INPersonHandle(value: "1233211234", type: .unknown), nameComponents: senderNameComponents, displayName: bestAttemptContent.title, image: profileImage, contactIdentifier: nil, customIdentifier: nil, isMe: false) let receiver = INPerson(personHandle: INPersonHandle(value: "1233211234", type: .unknown), nameComponents: nil, displayName: nil, image: nil, contactIdentifier: nil, customIdentifier: nil, isMe: true) let intent = INSendMessageIntent( recipients: [receiver], outgoingMessageType: .outgoingMessageText, content: "Test", speakableGroupName: INSpeakableString(spokenPhrase: "Sender Name"), conversationIdentifier: "sampleConversationIdentifier", serviceName: nil, sender: sender, attachments: nil ) intent.setImage(profileImage, forParameterNamed: \.sender) let interaction = INInteraction(intent: intent, response: nil) interaction.direction = .incoming interaction.donate(completion: nil) if #available(iOSApplicationExtension 15.0, *) { do { bestAttemptContent = try bestAttemptContent.updating(from: intent) as! UNMutableNotificationContent } catch { contentHandler(bestAttemptContent) return } } contentHandler(bestAttemptContent) } else { contentHandler(bestAttemptContent) return } } }
0
0
448
Sep ’23
Sorting Contacts
I am using the Contacts API for my iOS app to fetch contacts. I currently sort the fetched contacts alphabetically, but was wondering if there is any ability to rank and sort them by "highest interaction" (i.e. scan iMessage or phone call log to prioritize contacts)? Any insight would be appreciated. I don't think this is possible via the Contacts API from what I've read, and I haven't found any existing answer commenting on this.
1
0
778
Aug ’22
AppStore Review Sign-In Information
For users to create an account and access my app, I only have Apple Sign-in. What sign-in credentials do I provide when I submit my app to the appstore for review? If I try to create a dummy apple id account, I would have to provide a phone number to verify login from new devices, which is something I'd like to avoid, and even then don't know how I'd be able to relay the security code. Any help would be appreciated.
1
2
652
Mar ’22