in-app-subscription-example icon indicating copy to clipboard operation
in-app-subscription-example copied to clipboard

What are the limitations of the example?

Open jrobichaud opened this issue 1 year ago • 0 comments

Hi,

I am considering to base our server side on this implementation and then add later the communication with Apple and Android servers to get live updates.

However, I am trying to figure out if this example project is good enough for production and what limitations it has (Ex: A list of edge cases it does not support).

By example: in the following code, it fetches only the active subscriptions but I believe it should fetch at least 1 more day since end_date is a timestamp:

async function getActiveSubscriptions() {
  return knex('subscriptions')
    .where('end_date', '>=', new Date())
    .where('fake', false)
    .select(['id', 'latest_receipt', 'user_id', 'app']);
}

Freshly expired subscriptions are not going to refreshed to get the latest renewal.

Suggested fix:

    //...
    .where('end_date', '>=', new Date(Date.now() - 24  * 60 * 60 * 1000))
    .where('fake', false)
    .select(['id', 'latest_receipt', 'user_id', 'app']);
}

Because of purchaseUpdatedListener is not called with android play store on auto renewals, the backend may not be aware of a renewal at all.

jrobichaud avatar Oct 08 '24 19:10 jrobichaud