Post

Replies

Boosts

Views

Activity

Completion handler for presentLimitedLibraryPicker is called twice
Hey all, a question about PhotosUI. I see a weird behaviour when the completion handler for presentLimitedLibraryPicker gets called twice. The first one returns only one identifier, and the second one comes with all the selected photos. Here is the sample code import UIKit import PhotosUI class ViewController: UIViewController { let button = UIButton(type: .system) override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground view.addSubview(button) PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in } button.frame = CGRect(origin: view.center, size: .init(width: 200, height: 50)) button.center = view.center button.setTitle("Open Picker", for: .normal) button.addAction(UIAction(handler: { _ in PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self) { ids in print(ids) } }), for: .touchUpInside) } } After selecting 3 photos the output in the console will be like ["CC95F08C-88C3-4012-9D6D-64A413D254B3/L0/001"] //1 item ["CC95F08C-88C3-4012-9D6D-64A413D254B3/L0/001", "ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED/L0/001", "99D53A1F-FEEF-40E1-8BB3-7DD55A43C8B7/L0/001"] // 3 items
0
0
520
Apr ’23
How to know when user upgrades/downgraded/crossgrades their subscription on the client
Hey, in our app we show post-purchase flow when a user purchases a subscription and its appearance should depend on the type of purchase: upgrade, downgrade or crossgrade. I found a way how to get this type on the backend side but can not figure out how to get this within the app. I see that Transaction has isUpgraded property but it is always false even if I move from a lower service plan to a higher one. So, I have two questions: Is this actually possible to know on the client when the user upgrades, downgrades or crossgrades? If yes, then how? Thanks
4
1
2.0k
Jan ’23
StoreKit 2 object
Hello all, Looking for advice on how and when to initialize StoreKit class. Right now in our we create StoreKit object every time a user opens the Plans screen. The idea behind this is that the data is always up to date, so for example user cancels a subscription via Settings and then goes to the app, they will see that a plan is cancelled. But in the docs, Apple says to start to listen for transactions as close as possible to the app launch. Additionally creating StoreKit object multiple times leads a memory leak because of func listenForTransactions() -> Task<Void, Error> that contains Task.detached What is the "proper" way to work with StoreKit 2 object? Should I have only one instance of it and have some sort of sync method to run it every time a user is about to interact with the store or the current implementation is fine? Thanks
0
0
526
Dec ’22