Getting empty value in SKProduct array in iOS 17

63 Views Asked by At

I have this issue in iOS 17 only and it gets the intended value in iOS 16. I have this variable @Published var products: [SKProduct] = [] when I try to execute the following function

func getProduct(packageId: Int?) -> SKProduct? {
    switch packageId{
    case 1:
        return products.first(where: {$0.productIdentifier == IAPConstant.weeklyPremium})
    case 2:
        return products.first(where: {$0.productIdentifier == IAPConstant.yearlyPremium})
    default:
        return nil
    }
}

the code in case of iOS 17 returns 'nil' i.e.

(lldb) po selectedProduct
 nil

the same code in case of iOS 16 returns this:

(lldb) po selectedProduct
▿ Optional<SKProduct>
- some : <SKProduct: 0x600001258bc0>

I am clueless why it's happening in iOS 17 only. Any complete/temporary fix would be appreciated as it has stopped the in app purchase for iOS 17 users.

0

There are 0 best solutions below