请求用户使用Swift在App Store上购买应用程序的日期

时间:2022-11-19 15:06:26

I have a paid app that has been on the App Store for a year.

我有一个付费的应用程序已在App Store上一年。

I am wanting make two changes to this app; 1) make the app free, and, 2) add advertising. But, I’m wanting to ensure that current users who purchased the app never see advertising.

我想要对这个应用程序进行两处更改; 1)使应用程序免费,并且,2)添加广告。但是,我想确保购买该应用的当前用户永远不会看到广告。

Two solutions I have considered:

我考虑过两个解决方案:

I could either completely delete the current app from iTunesConnect and the App Store then submit a brand new replacement app with a new Bundle ID.

我可以从iTunesConnect和App Store中完全删除当前的应用程序,然后使用新的Bundle ID提交一个全新的替换应用程序。

Alternatively, in the current app, I could make a request to the App Store and check when the user first purchased the app as a way to determine whether or not to display advertising or not.

或者,在当前的应用程序中,我可以向App Store发出请求,并检查用户何时首次购买应用程序,以确定是否显示广告。

On the developer website I’ve read ‘Validating Receipts With the App Store’ and understand StoreKit and appStoreReceiptURL are involved, but am no clearer as to how to implement and achieve this in Swift 2.

在开发者网站上,我读过“使用App Store验证收据”并了解StoreKit和appStoreReceiptURL,但是如何在Swift 2中实现和实现这一点并不清楚。


Question:

题:

Anyone experienced with such matters, in Swift 2, how do I make a successful request to the App Store and check the date when the user purchased the app?

任何有这些问题的人,在Swift 2中,如何向App Store提出成功请求并检查用户购买应用程序的日期?

1 个解决方案

#1


-1  

I don't think you can get the purchase date in your code. As a workaround you could check for the app version:

我认为您不能在代码中获得购买日期。作为解决方法,您可以检查应用程序版本:

    if let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String {
        let versionNumber = Float(version)

        if versionNumber < 1.xx
        { 
           // .. Do something
        }
    }

#1


-1  

I don't think you can get the purchase date in your code. As a workaround you could check for the app version:

我认为您不能在代码中获得购买日期。作为解决方法,您可以检查应用程序版本:

    if let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String {
        let versionNumber = Float(version)

        if versionNumber < 1.xx
        { 
           // .. Do something
        }
    }