问题
In iTunes Connect it is possible to give a free trial period for autorenewable subscriptions.
App > Manage In App Purchases > Subscription Basic > 1 Month > Offer a free trial?
How can I get this information on the client? SKProduct
does not have any information about this as I can see. Since we're having a marketing campaign it is very confusing for the end user to not see information about the product has a trial period.
Of course it is possible to fetch this kind of information from a server I maintain, but then we'll have the overhead with updating both our server and iTunes Connect. So I don't accept this kind of answer unless it is wired up to retrieving that trial period information from Apple's services.
回答1:
SKProduct > introductoryPrice
Available since iOS 11.2
https://developer.apple.com/documentation/storekit/skproduct/2936878-introductoryprice?language=objc
回答2:
TLDR; It is not possible. You need to manage this information yourself.
When you process an SKPayment you get back a receipt. You should verify those receipts regularly for subscriptions (e.g. before downloading new content) as the user might have cancelled the subscription. When the user does cancel the subscription or the subscription expires you get back a descriptive error when verifying the purchase's receipt.
Moreover the receipt gives you all the information you need: for a given product you know which trial period you grant. Therefore when a purchase is made you could store the purchase date given from the purchase receipt in your model object or in the NSUserDefaults or in the Keychain alongside the purchase data. At this point you know when the trial is expired and verify that the subscription is still valid. If you can't you might want to disable access to the content until you're able to do so.
For more informations about purchase receipts and subscriptions check out the In-App Purchase Guide by Apple.
回答3:
On the client side you usually identify the different products and characteristics by their product identifier as the App Store does not deliver certain information such as subscription period and free trial period.
So if your product ID is for example:
com.domain.app.product_paid1month_free7days
you split the ID on the client side and know that the paid subscription duration is 1 month
and the product has a free trial period of 7 days
.
Of course one approach would be to transmit the product ID to your own server to get its characteristics as response. This way you can maintain the product list continuously without updating the binary and across versions.
来源:https://stackoverflow.com/questions/16912969/storekit-on-ios-autorenewable-subscription-how-to-know-whether-it-is-a-free