简体   繁体   English

仅使用 IAP 的无效产品 ID iPad

[英]Invalid product id with IAP only with iPad

My in-app purchases do not work with the iPad but work pretty well via the iPhone.我的应用内购买不适用于 iPad,但在 iPhone 上效果很好。 From the technology and logic part, it shouldn't be like that.从技术和逻辑上来说,不应该是这样的。 I can not find any info connected to that issue.我找不到与该问题相关的任何信息。 As I saw in the terminal, it returns an invalid product identifier if I run it on the iPad simulator.正如我在终端中看到的那样,如果我在 iPad 模拟器上运行它,它会返回一个无效的产品标识符。 But with simulation on all iPhone models, everything runs well.但是通过对所有 iPhone 型号的模拟,一切都运行良好。 It should not be like that because referencing the official documentation works the same on both systems.它不应该那样,因为参考官方文档在两个系统上的工作方式相同。

Here is the fetching function:这是获取 function:

public func fetchProducts(){
        let request = SKProductsRequest(productIdentifiers: Set(Product.allCases.compactMap({ $0.rawValue })))
        request.delegate = self
        request.start()
    }

I call it like that:我这样称呼它:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        IAPManager.shared.fetchProducts()
        FirebaseApp.configure()
        
        return true
    }

And that function is a part of the Singleton class. function 是 Singleton class 的一部分。

So when I tried to buy an Item I retrieved that in terminal, because the array of fetched products was empty.所以当我试图购买一个项目时,我在终端中检索到了它,因为获取的产品数组是空的。 With iPhones, the function works correctly and fetches all the products.对于 iPhone,function 可以正常工作并获取所有产品。

2022-12-15 17:53:46.397764+0100 Quotely[63397:3419642] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'

I found the answer to my question, maybe someone else will come across a similar one.我找到了问题的答案,也许其他人会遇到类似的问题。 I just created a new StoreKit configuration file and everything started working fine with it.我刚刚创建了一个新的 StoreKit 配置文件,一切都开始正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM