4
votes

I have an app with in-app auto-renewable subscriptions all configured and working OK. I face a tricky problem where I would need my server to be aware of a renewal even though the user has not re-open his app since the renewal.

The way I implemented the in-app purchase support is that the app registers a SKPaymentTransactionObserver and gets called when new payments are made. Then the app calls my server which verifies the receipt with Apple and extends the subscription period for the user.

Meaning that if at the end of a period the user does not open my app, I am not aware that the subscription is extended because the server will never be updated with the new receipt...

... BUT when a user purchase a subscription, it enables features for him and for others. And since he has paid, the features he enables for others should work.

Is there a way for my server to ping apple and get new payment transactions so that I can register the information, should the user has or has not open the app?

1
Reply back if you figure out an elegant solution. So far what I'm trying to do for my app is save the receipts on the server and use a cron to validate the receipts that are within 10 days of expiration every night.Brian
This is a really good question. I am facing the same issue. Can anybody help here?Jogi Thakur
you can use background refresh, for the awake your app and sent details to the server.Ilesh P

1 Answers

3
votes

You should use server notifications from the App Store (Or Server to Server notifications), he send to server - "users' subscription status changes".
https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_status_update_notifications

And more information about handling subscriptions
https://developer.apple.com/documentation/storekit/in-app_purchase/handling_subscriptions_billing

Some guide can be help for you
https://tech.busuu.com/how-we-implemented-apple-server-to-server-notifications-8ae63bcce4bb