StoreKit on iOS - autorenewable subscription - How to know whether it is a free trial or not? - iphone

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.

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.

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.

SKProduct > introductoryPrice
Available since iOS 11.2
https://developer.apple.com/documentation/storekit/skproduct/2936878-introductoryprice?language=objc

Related

What is the correct way to determine if user is eligible for free trial with local receipt validation on a Mac App?

I am parsing receipts for an auto renewing subscription locally on a Mac app.
From this document, it would seem that receipt field 1719 should come back as true (1) when user is in the free trial or introductory pricing.
I've tried this out with the local Xcode configuration (StoreKit testing) and it does come back as true, but this never happens in Sandbox (always 0). Should this be working in production?
Does "introductory price period" (field 1719) not imply the free trial?
The same question is being asked in this Apple forum, but it's from some time ago and doesn't appear that anyone has a clear answer.
To determine if a user is eligible for an introductory offer, you must check the values of the is_trial_period (1713) and the is_in_intro_offer_period (1719) for all in-app purchase transactions. If either of these fields are true for a given subscription, the user is not eligible for an introductory offer on that subscription product or any other products within the same subscription group.
Personally, I use and recommend TPInAppReceipt library, it provides a variety of convenience methods to validate receipt, determine introductory price eligibility and more. It works well in all possible environment (Sandbox, Production, StoreKitTest).
Does "introductory price period" (field 1719) not imply the free
trial?
If you want to check whether a user's subscription is currently in the free trial period you can check is_in_intro_offer_period value.
The easiest way I've found to check for free trial eligibility in LOCAL receipt validation is to simply check for the number of IAP receipts. If this is empty, the user should be eligible for the free trial, otherwise you can assume that the free trial has already been used.

Can I give my iPhone App customers referral credits for signing up new subscription customers

In an app that is free, but has in-app subscription purchases I would like to allow a user with a paid subscription to receive x number of free months on top of the paid subscription if he refers someone that purchases a subscription.
For this to work it would have to be possible to track some sort of unique token through the Apple App Store in order to reliably assign credits.
To "Refer a friend" the app would allow the user to send an email to one or more people. This email would contain a link to the app store that also contains a unique key that I would generate to track the lead.
Is this possible?
Our app just got rejected yesterday regarding this kind of functionality.
We had an application which includes yearly subscriptions to access premium features. We also had a way for users to refer 5 friends to get a free access for life to our services. Apple rejected the app stating that this was against their rules for IAP.
Specifically, they referred us to the section 11.1 of the guideline which states :
Apps that unlock or enable additional features or functionality with mechanisms other than the App Store will be rejected
Unfortunately, apple doesn't offer that functionality. One option is to offer 2 different subscriptions - paid and free.
Hide the free subscription portal until they refer someone - then allow them to see the free subscription option.
A couple problems:
The user will have to manually cancel auto-renew on their current paid subscription and then manually sign up for the free subscription.
I don't think you will be able to disable auto-renew on the free subscription option, so it would probably end up being permanent.
You could skip the free subscription official IAP and just make your own time-limited "back door" letting the customer continue downloading subscription content without verifying their App Store receipt. This would still have problem (1) above with the customer needing to manually cancel their auto-renew and then repurchase the subscription when their free time runs out.
My gut tells me this is going to be REALLY hard to pull off in a satisfactory way.
It would be much easier to reward one-time exclusive content for referrals. E.g. Give X for the first, Y after 5 referrals, Z after 10 referrals, etc. This is actually an easier value proposition to present to the users too; make a nice icon or something with an "Invite Friends to Unlock!" call to action.

iOS In App subscription - detecting the opt-in marketing incentive extension

How do you detect that the purchaser of an In App auto-renewable subscription has selected to provide marketing data so that you can give them a 7 or 30 day extension of the subscription time period?
My understanding is that since Apple is responsible for automatic renewals, the onus is on Apple to grant your customers who opt in an extension when you answer "Yes" to the question "Offer a marketing opt-in incentive?" in iTunes Connect.
There's no way to programmatically detect an opt-in.
I just spoke to Apple directly (August 19th 2012) and they informed me that the documentation about determining the length of auto-renewing subscriptions is wrong and will be updated.
Checking the expires_date is the correct way to determine the subscription expiration. That date will be adjusted depending on whether the user chooses the opt-in marketing incentive and also whether they've been offered a free trial (for Newsstand apps) or not. It's critical to pay attention to the expires_date and not just assume durations based on the product ID.
That information will also be included on restored transactions.
There seems to be some confusion here. To clarify:
You can offer a free/extended subscription period to users who provide marketing information to you
This marketing information is available for review in iTunes Connect
You set up the incentive subscription in iTunes Connect when you create the subscription product
So when you go into iTunes Connect and create a new auto-renewable subscription in the in app purchase section there's a check box labelled 'Offer a marketing incentive?'. If you check 'Yes' you'll be able to select the length of incentive you'd like to offer, which ranges from seven days to one year.
Just use Apple's procedure for Verifying Store Receipts* to discover the expires_date. Then provide the user access to your service up until the expiration date. If you want to determine if they opted in, you could try comparing the purchase_date to the expires_date to determine the length of the subscription. If it's longer than the period of your product, they probably opted in.
Be aware that purchase_date may not be the actual date the product was purchased if this transaction was restored. However, it appears that original_purchase_date is the date the user first initiated any subscription with you. Even if the subscription has renewed multiple times, or lapsed and restarted.
*
See here for a brief Summary of the Receipt Verification Procedure.
The docs state:
"The expiration date of the subscription receipt, expressed as the number of milliseconds since January 1, 1970, 00:00:00 GMT. This key is not included on restored transactions."
So if you restore the transactions you do not get this value. What to do in that case?

How to handle a auto-renewing subscriptions as a developer

In the this Article Apple wrote how to enable an auto-renewing subscription from the users point of view. But my question is how to handle this auto-renewing subscription as the developer of an app?
In my app (currently in developing) the user can buy some subscriptions (30 days, 3 months and 1 year) via in-app-purchase. After a successful payment I send the bought item identifier to my server to save the new subscription time (also used for other platforms). This works perfectly in the sandbox-environment.
But if I correctly understand the article the auto-renewing subscriptions is performed from inside the AppStore and inside my app. How can I now track the subscription?
If a subscription is autorenewed, the transaction won't pass the paymentQueue:updateTransactions method. The renew just happens on the Store.
If you want to test for it you have to either:
Revalidate the receipt on your application server, if you store the receipt there.
Revalidate the receipt on your iOS client
See: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingStoreReceipts.html#//apple_ref/doc/uid/TP40008267-CH104-SW1
In order to avoid testing for an autorenew each launch/activation you should store the endDate of the subscription period to test for a renew afterwards.
Also see: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html#//apple_ref/doc/uid/TP40008267-CH4-SW4
However, there seems to be a bug in the sandbox. Subscriptions sometimes get renewed, sometimes not. Hard to test....
based on the (rather scant) info found in apple's in-app-purchase documentation, my impression is that whenever you need to determine the state of a user's auto-renewal subscription, you would restore their transactions.
this would cause the app store to send all auto-renewal transactions to your app, at which point you would process the receipts and make the appropriate content available.
presumably, you would only need to do this when the user's current subscription (which you can track locally) is set to expire, or when they are first installing the app.

Does the iphone app store provide instant payment notification to a url?

I'm considering posting an app to the iphone app store, but I'm curious before I start paying them for the priviledge of posting the app, whether they provide instant payment notification to a url?
Generally, I've used paypal in the past for applications where right after payment my web site is secretly notified of a purchase. I take this notification, with the users email address and product purchased, to send the purchaser information required for the application.
Is this possible with apple? With the iphone app store? What about the upcoming mac store?
thx
No. Apple handles all contact with the customer, including delivery of the app. At the end of each day, week and month they give you summaries of sales of each product in each country. It's nothing like selling with PayPal. The iOS and Mac App Store are exactly the same in this regard.
The nearest you can get is having your app connect to your server when it first runs, although if you're doing this for no other reason than to track your users, you'll have to check it's allowed under the developer agreement.
First, no, you do not receive instant notification. You can grab a daily report on the web the following early morning (in the US), you can use the free app that Apple provides to retrieve the information, or you can use a variety of third-party tools to do the same.
Second, you will never receive any information whatsoever about the people who buy your app, so no, you can't send purchasers anything.
The Mac App Store appears to use the exact same arrangements.
If you use in-app purchase, you can get an instant notification to your server for the in-app purchase, but not for the initial download of the app.
If you just place a paid app in Apple's App store, you get no direct sales or customer information of any kind, only after-the-fact daily and weekly sales trend estimates, and monthly sales reports a few weeks later. Then Apple then pays you 70% of what they reported up to 45 days after the monthly close. You don't pay them. They pay you. And with over 300K apps in their store, and no other store doing anywhere near as well, they need no privileges granted from any developer. It's more like take it or leave it.