Post

Replies

Boosts

Views

Activity

Live Activity not showing when started via push notification, but alert is received and app dismisses to dynamic island
I am trying to start a live activity via push token with the below headers and payload. I am using the 'fetch-http2' npm module to execute the APNS request in a deno/typescript environment, and am authenticating via token/p8. The device receives the alert portion of the payload, but the live activity does not appear on the device. I get a 200 OK response from APNS with the unique ID, and dashboard shows notification was successfully sent to the device. The odd thing, when backgrounding the app dismisses to the Dynamic Island with the animation as if there were a live activity happening, but there is not. When I check Activity<MyAttributes>.activities on app launch, it's empty. I don't see any errors in Xcode when I have the app running/foregrounded when sending the request. Quitting the app restores normal behavior. TL;DR: I have regular APNS alert push notification requests working without issue from the same environment. However when attempting to start a live activity via APNS, the alert is received but the live activity does not appear, despite the app/system seemingly thinking there is one. What could I be missing, or what else could I try? I have checked that: My generated JWT and device token are valid according to CloudKit dashboard (again, standard push alerts are working as expected) I can successfully start a live activity locally/from foreground via Activity.request I have added Supports Live Activities and Supports Live Activities Frequent Updates to my app's info.plist, and also have the required capabilities enabled (remote push, background processing, background fetch) I am using the current device push-to-start token (obtained from device via Activity.pushToStartTokenUpdates) for the device token in the APNS request (NOT the update token) My ActivityAttributes and ActivityAttributes.ContentState values and types are correct "headers": { "authorization": "bearer {jwt}", "apns-push-type": "liveactivity", "apns-topic": "{bundleId}.push-type.liveactivity" } "aps": { "attributes-type": "LiveActivityAttributes", "attributes": { "title": "Test Event" }, "content-state": { "status": 1 }, "event": "start", "alert": { "title": "Alert Title", "body": "Live Activity has started." }, "sound": "default", "timestamp": Math.round(Date.now() / 1000) }
3
0
1k
Aug ’24
APNS push is not received by device when sent via backend despite 200 OK response received
I am attempting to send a push notification via APNS from a supabase edge function (deno/typescript). I receive a 200 OK response from APNS, and using the "apns-unique-id" I am able to look up the notification in the dashboard which shows the notification was successfully sent to the device. However the app/device does not receive the push. Using the dashboard, I can successfully send a test push to the device, and I also have FCM already implemented and working, so I assume the iOS/client-side setup is not the problem. I also verified that my generated JWT and device token are valid via the dashboard, plus I'm getting 200 back with the request, so I also assume that auth is not an issue either. Yet even with a simple alert payload such as below, nothing comes through. What else could be causing this issue? Perhaps I'm missing a step? The details of the request I'm making are below: url = "https://api.sandbox.push.apple.com:443/3/device/{deviceToken}" headers = { "authorization": "Bearer {jwt}", "apns-push-type": "alert", "apns-topic": bundleId, "apns-priority": 10 } body = { "aps": { "alert": { "title": "Test Notification", "body": "This is a test notification.", "sound": "default" } } }
1
0
825
Jul ’24
What happened/changed with UICollectionViewCompositionalLayout and dynamic/auto-sizing cells and headers/footers?
Since UICollectionViewCompositionalLayout released, I've been able to create dynamic-height UICollectionViewCells without issue using AutoLayout. However, I noticed today that it seems this no longer works. I have tried all combinations of setNeedsLayout, layoutIfNeeded, changing the autoresizing mask on the cell, header, collectionView, labels... nothing changes. However, it DOES correctly size the header/cell once they are reused. If you run the example code below, scroll down until they are off-screen, and they will be correctly re-sized when they reappear (which is how they used to appear on first load). So what is wrong with the below code? Previously, this would correctly size the header and cell to fit the content (in this case, a multi-line label). Is there something obvious I'm missing? The code below is the same format I've been using for over a year without issue until now. All suggestions/advice welcome! macOS Ventura 13.3.1 Xcode 14.3.1 Running on iOS 16.4 simulator Issue also present in iOS 16.0 simulator Issue also present on physical device (iPhone 14 Pro Max, iOS 16.5.1) ViewController: class ViewController: UIViewController { enum Section: Int, CaseIterable { case main } private var collectionView: UICollectionView! private var dataSource: UICollectionViewDiffableDataSource<Section, AnyHashable>! override func viewDidLoad() { super.viewDidLoad() setupViewController() setupCollectionView() setupDataSource() updateData() } private func updateData() { var snapshot = NSDiffableDataSourceSnapshot<Section, AnyHashable>() snapshot.appendSections(Section.allCases) snapshot.appendItems(Array(0..<1), toSection: .main) dataSource.apply(snapshot, animatingDifferences: true) } private func setupViewController() { navigationItem.title = "Title" view.backgroundColor = .systemGroupedBackground } } extension ViewController: UICollectionViewDelegate { private func setupCollectionView() { collectionView = UICollectionView(frame: .zero, collectionViewLayout: makeLayout()) collectionView.backgroundColor = .clear collectionView.delegate = self collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) NSLayoutConstraint.activate([ collectionView.topAnchor.constraint(equalTo: view.topAnchor), collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor) ]) } private func setupDataSource() { let header = UICollectionView.SupplementaryRegistration<CustomHeader>(elementKind: UICollectionView.elementKindSectionHeader) { header, kind, indexPath in header.set(headerText: "A really really long header title that is so long that it cannot fit on a single line, so it must span multiple lines.") } let cell = UICollectionView.CellRegistration<CustomCell, AnyHashable> { cell, indexPath, item in cell.set(cellText: "A really really long chunk of text that is so long that it cannot fit on a single line, so it must span multiple lines.") } dataSource = UICollectionViewDiffableDataSource<Section, AnyHashable>(collectionView: collectionView) { collectionView, indexPath, item in return collectionView.dequeueConfiguredReusableCell(using: cell, for: indexPath, item: item) } dataSource.supplementaryViewProvider = { collectionView, kind, indexPath in return collectionView.dequeueConfiguredReusableSupplementary(using: header, for: indexPath) } } private func makeLayout() -> UICollectionViewLayout { return UICollectionViewCompositionalLayout { sectionIndex, environment in let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(50)) let item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(50)) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) let section = NSCollectionLayoutSection(group: group) section.contentInsets = NSDirectionalEdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20) let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(50)) let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: UICollectionView.elementKindSectionHeader, alignment: .top) section.boundarySupplementaryItems = [header] return section } } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { collectionView.deselectItem(at: indexPath, animated: true) } } Screenshot
2
0
984
Jun ’23
Xcode 13.1 "Making device ready for development" issue - Unable to run on a physical device
Xcode 13.1 (13A1030d) 14" MacBook Pro (M1Pro 10/16 cores) iPhone 13 Pro Max 512GB I'm having an issue with running projects on a physical device. Xcode gets stuck on "Making the device ready for development" when trying to run a physical device. In Devices and Simulators, I see a variety of errors: "Could not locate the device support files - Xcode could not determine the device type" "Failed to cache symbols for watch (null) connected to Travis's iPhone - Unknown reason. If you are using a supported combination of hardware, please reboot and unlock all devices (including the host Mac) and respond to any outstanding pairing requests" There are no outstanding pairing requests. I have un-trusted and re-trusted my MBP from my iPhone and Apple Watch, and have unpaired & repaired my Apple Watch to my iPhone. I have completely shut down and rebooted all devices (iPhone, Mac, Apple Watch). I have connected & reconnected with 3 different lightning cables, 2 of which are brand new from Apple. I have cleared derived data for Xcode. Nothing fixes. Usually after 4-5+ attempts of cancelling & re-running gets it to finally go through, but not always. Very annoying.
4
0
2k
Nov ’21
Managing UISplitViewController displayMode with orientation change & multitasking in iOS 14?
I'm using a UISplitViewController with a triple column style, with .displayMode set to .twoBesideSecondary in order to show all 3 columns. In landscape, there is plenty of room on iPad to display all 3 columns. In portrait orientation, or when there's another app on screen in side-by-side multitasking, the screen is too narrow, and my 3rd column ("secondary" view controller) gets completely squished to a very narrow width. What I would like to do is switch the .displayMode property to .twoDisplaceSecondary in these cases so that the content in the secondary VC gets pushed off screen, rather than squished. A great example of exactly what I want to do is the Contacts app on iPad. When in landscape, all 3 columns are fully shown. When an app is brought on screen for multitasking, it is detected somehow and the .displayMode changes to .twoDisplaceSecondary, and the 3rd column is pushed off screen rather than getting squished. I think I know how to manage detecting orientation changes (using viewWillTransitiontoSize) so I can manage landscape vc. portrait displayMode, but I'm not sure how to detect when another app is present in multitasking. Thanks!
2
0
1.5k
Jul ’20
UISplitViewController - Sidebar large titles with UICollectionView? (iOS14)
I'm learning about setting up a new UISplitViewController in iOS/iPadOS 14. I have primary, supplementary, and secondary view controllers configured on the splitViewController using setViewController(for:) method. I'm using the primary view controller as a Sidebar, and have prefersLargeTitles set to true on it. It seems like when I set up a UICollectionView in the Sidebar view controller, it causes the large title to go away. Configuring the collection view via frame (collectionView.frame = view.bounds), or via programmatic constraints doesn't seem to matter - the large title goes away either way. Is this a bug, or is there something I'm doing wrong? Thanks!
3
0
1.5k
Jun ’20