Lorixen.
EN

Keeping app subscriptions in sync with store server notifications

Short answer: If your app sells subscriptions through the App Store or Google Play, your server shouldn't wait for the app to open to find out a subscription renewed, failed or was refunded. Apple's App Store Server Notifications and Google Play's real-time developer notifications (RTDN) tell your server when something changes. Set up an endpoint for each, treat each message as a prompt to fetch the current state from the store's API, store that state, and use it as the single source of truth for access across your app and website.

The problem: the app only knows what it's told

Many small subscription apps check purchases on the device. That works until:

  • A subscriber cancels in their phone settings, and your web dashboard still shows them as paying.
  • A refund goes through, but the user keeps premium features.
  • A renewal fails and recovers, and your support team can't tell what happened.
  • A user signs in on a second device or your website, which has no way to see the store purchase.

Server notifications fix this by telling your back end directly.

Apple: App Store Server Notifications

Apple's documentation explains that you give App Store Connect an HTTPS URL on your server to receive notifications about in-app purchase events. A few points from the setup and response guides:

  • Choose version 2. App Store Connect lets you choose version 1 or version 2 notifications for each environment. Version 2 is the current format, and the examples below assume it.
  • Production and sandbox. You can set a separate sandbox URL for testing, or use the same URL for both environments.
  • Test it. You can ask Apple to send a TEST notification and check how your server responded through the App Store Server API.
  • Respond correctly. Return HTTP 200, or any code from 200 to 206, when you've received the notification. A 40x or 50x response tells Apple to retry. Apple says it treats any other code as an unsuccessful post.
  • Retries. For version 2, Apple retries five times, at 1, 12, 24, 48 and 72 hours after the previous attempt. If your server is down for a weekend, notifications still arrive, but late.
  • Recovering missed messages. Apple's server API includes a Get Notification History endpoint, useful after an outage.

Notifications carry a notification type such as a renewal, a failed renewal (DID_FAIL_TO_RENEW) or a refund, signed by Apple. Check the signature using Apple's own libraries or documented method before trusting the content.

Google Play: real-time developer notifications

Google's setup guide describes RTDN as notifications sent when a user's entitlement changes. They use Google Cloud Pub/Sub: you create a topic, connect it in the Play Console, and either have messages pushed to a URL you set or pull them with a client library.

Google's RTDN reference is clear on one point. The notification tells you only that the purchase state changed; it doesn't give you complete information about the purchase. You must call the Google Play Developer API to get the full status and update your back end.

A subscription notification contains a version, a notification type and a purchase token. Types include SUBSCRIPTION_RECOVERED (recovered from account hold or resumed from pause), SUBSCRIPTION_RENEWED and SUBSCRIPTION_CANCELED, among others. Each Pub/Sub message carries the notification as a single base64-encoded data field. There's also a test notification you can trigger from the Play Console.

A pattern that works for both stores

Treat every notification as "something changed, go and look":

  1. Receive. Accept the message at your endpoint or Pub/Sub subscription.
  2. Verify. Check Apple's signature, or make sure the push came through your authenticated Pub/Sub subscription.
  3. Acknowledge quickly. Store the raw message and return success straight away. Do the slower work in a background job, so a slow database doesn't cause the store to retry.
  4. Fetch the current state. Call the App Store Server API or Google Play Developer API with the transaction or purchase token.
  5. Update your records. Save the subscription's state, expiry time, product and the user it belongs to.
  6. Apply access rules. Your app and website read access from your records, not from the device.

Handling the awkward bits

Duplicates and order. Notifications can arrive more than once, and not always in the order events happened, especially after retries. Because you always fetch the latest state from the store's API, a duplicate or late notification is harmless: you simply store the same current state again.

Linking purchases to users. A store purchase knows about an Apple or Google account, not your customer account. When the app makes a purchase, send the purchase details to your server along with the signed-in user, so later notifications can be matched. Both stores support attaching your own identifier to a purchase; use it.

Refunds. Decide in advance what a refund means for access and for anything already delivered, such as downloaded content or credits.

Logging. Keep a history of notifications per subscription. When a customer says "I was charged but have no access", support can see the sequence of events.

Monitoring. Alert if notifications stop arriving entirely for longer than you'd expect. A changed URL or an expired credential can silently cut the feed.

What changes for your customers

Once this is in place, a cancellation on the phone shows up on the website, refunds remove access consistently, and renewals that recover from a payment failure restore access on every device. Support can answer questions from a clear record instead of guessing.

A worked example

A hypothetical Galway language-learning app sells monthly subscriptions on iOS and Android and also has a web version. Web users were often shown as premium after cancelling on their phones. The developer set up App Store Server Notifications version 2 and Play RTDN through Pub/Sub, both feeding one endpoint that stores the message and queues a job. The job fetches the current status from each store's API and updates a single subscriptions table, and every platform checks that table. A weekly check compares active subscriptions in the table with a sample of store records.

FAQ

Do I still need to validate purchases in the app?

The app should still send new purchases to your server. Notifications then keep that record up to date.

Can I use a third-party subscription service instead?

Yes. Several services receive these notifications for you and expose a simpler API. You still need to decide your own access rules.

What if my server is down?

Apple retries on a schedule and offers notification history; Pub/Sub keeps undelivered messages for a period. Reconcile after any outage.

Are sandbox and production handled separately?

Use separate URLs or check the environment field, so test purchases never grant real access.

If your app's subscription records don't match what the stores say, tell us how your back end tracks them.

Sources

WhatsAppBook a call