Skip to content

Check if in-app purchase has been made on start #88

@Twansparant

Description

@Twansparant

Hi there,

I'm a bit lost on how to achieve the following workflow:

  • When opening my app, check if the currently logged in user (in App Store) has already purchased my in-app purchase by either checking a local storage item and if not present, checking existing receiptData using the InAppUtils.receiptData function.

  • Add Get Full App button for purchasing in-app premium content using the InAppUtils.loadProducts & InAppUtils.purchaseProduct functions.

  • Add Restore Purchase button for manually restoring previous in-app purchase using the InAppUtils.restorePurchases function.

I'm confused what the receiptData actually contains? Does it contain ALL receipts from ALL the apps from the logged-in user? Or just the receipts from my app?

If I would just use this as a check for the in-app purchase, it will always enable the premium content:

InAppUtils.receiptData((error, receiptData)=> {
  if(error) {
    AlertIOS.alert('itunes Error', 'Receipt not found.');
  } else {
    // enable premium content
  }
});

With the InAppUtils.restorePurchases function you CAN check if the current purchases contain your in-app purchase, but that requires logging in to your AppStore account everytime/most of the time, so not ideal for step 1 of my workflow.

So my question is, how should I validate the receiptData? I don't have a server for my app.
I found this module for validating receipts, but I can't get it working yet with rn-nodify.

Any help is appreciated.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions