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) }
1
0
529
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
503
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
826
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
1.9k
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.4k
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.3k
Jun ’20
AVPlayerViewController/SceneDelegate bug? AVPlayerViewController in full screen goes black with pan/cancelled swipe gesture
I'm getting a weird bug with an AVPlayerViewController presented to full screen from inline/embedded state. The bug is triggered when you begin to swipe to dismiss out of full screen, but then cancel the dismissal (i.e. try to keep the video full screen). The video tries to stay full screen but then just goes black, and the whole app becomes unresponsive while the audio still plays.I downloaded Apple's Using AVKit in iOS sample project after watching the Delivering Intuitive Media Playback with AVKitsession from WWDC19. In their sample project, they have an AVPlayerViewController embedded inline in a cell, and when the user taps the expand arrows, it goes full screen. While in full screen, the user can pan the video around in any direction without issue. Completing the pan/swipe gesture in a downward motion completes the dismissal and the view dismisses from full screen.In my project (Xcode 11.4) I'm embedding an AVPlayerViewController exactly how Apple does in their sample project, yet when I pan the video in full screen, the video goes black and the app has to be restarted (if I complete the swipe to dismiss gesture, it does dismiss correctly without issue, but you have to be very specific about it). Interestingly, I rebuilt my own code (below) inside Apple's demo Xcode project and everything works fine!The sample project says it's supposed to be exactly for the 2019 WWDC session and is compatible with Xcode 11+, however under "Project Format" in general settings the sample project says it's Xcode 9.3 compatible, and it doesn't have a SceneDelegate which was introduced with iOS 13.So in conclusion, could this be a bug with AVPlayerViewController and SceneDelegate? Or is there something I am missing?Here's the exact ViewController I'm using that works in Apple's sample project, but does NOT work in Xcode 11.4:class ViewController: UIViewController { let videoContainer = UIView() let padding: CGFloat = 20 override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemGroupedBackground title = "Video" navigationController?.navigationBar.prefersLargeTitles = true configure() embedVideoInline(in: self, container: videoContainer) } private func configure() { videoContainer.backgroundColor = .secondarySystemGroupedBackground videoContainer.translatesAutoresizingMaskIntoConstraints = false view.addSubview(videoContainer) NSLayoutConstraint.activate([ videoContainer.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: padding), videoContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding), videoContainer.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding), videoContainer.heightAnchor.constraint(equalToConstant: ((view.frame.width - padding*2)/16) * 9) ]) } func embedVideoInline(in parent: UIViewController, container: UIView) { let url: URL! = URL(string: "https://www.radiantmediaplayer.com/media/bbb-360p.mp4") let playerItem = AVPlayerItem(url: url) let playerViewController = AVPlayerViewController() playerViewController.player = AVPlayer(playerItem: playerItem) parent.addChild(playerViewController) container.addSubview(playerViewController.view) playerViewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ playerViewController.view.centerXAnchor.constraint(equalTo: container.centerXAnchor), playerViewController.view.centerYAnchor.constraint(equalTo: container.centerYAnchor), playerViewController.view.widthAnchor.constraint(equalTo: container.widthAnchor), playerViewController.view.heightAnchor.constraint(equalTo: container.heightAnchor) ]) playerViewController.didMove(toParent: parent) } }
1
0
1.2k
Apr ’20