如何将用户与涉及Apple状态通知的自动续订订阅相关联?

时间:2023-01-12 21:39:09

How do I associate an auto-renewable subscription in a way that lets me know which notifications are for which users in MY database? Is there some sort of id from the original receipt that I can store as a field for a User?

如何以允许我知道哪些用户在MY数据库中为哪些用户通知的方式关联自动续订订阅?原始收据中是否存在某种ID,我可以将其存储为用户的字段?

It is great that I know when a user cancels or renews, etc but it doesn't help that I am not sure which user this is happening for.

很高兴我知道用户何时取消或续订等,但这对我不确定发生了哪个用户没有帮助。

When you visit the docs and scroll down to Status Update Notifications, you'll notice that status notifications do have an original_transaction_id field, is this something that persists and can be relied on?

当您访问文档并向下滚动到状态更新通知时,您会注意到状态通知确实有一个original_transaction_id字段,这是否会持续存在并且可以依赖?

1 个解决方案

#1


1  

Yes, you can use original_transaction_id. It's property saved for all renews.

是的,您可以使用original_transaction_id。所有续订都保存了该属性。

If the user cancels their subscription and buys a new subscription, then original_transaction_id will change.

如果用户取消订阅并购买新订阅,则original_transaction_id将更改。

However, if the user upgrades or downgrades their subscription, original_transaction_id will not change.

但是,如果用户升级或降级其订阅,则original_transaction_id不会更改。

This is supported on modern versions of iOS, including iOS 10.

iOS的现代版本支持此功能,包括iOS 10。

Another way to do it is to save an array of transaction_id values and associate these with user accounts. Depending on your needs, this might work better for you.

另一种方法是保存一系列transaction_id值并将其与用户帐户相关联。根据您的需要,这可能对您更有效。

UPD by Stafox: time-to-time original_transaction_id may changes after renew and may still the same after cancel and resubscribe.

Stafox的UPD:续订后的原始时间original_transaction_id可能会发生变化,取消和重新订阅后可能仍然相同。

#1


1  

Yes, you can use original_transaction_id. It's property saved for all renews.

是的,您可以使用original_transaction_id。所有续订都保存了该属性。

If the user cancels their subscription and buys a new subscription, then original_transaction_id will change.

如果用户取消订阅并购买新订阅,则original_transaction_id将更改。

However, if the user upgrades or downgrades their subscription, original_transaction_id will not change.

但是,如果用户升级或降级其订阅,则original_transaction_id不会更改。

This is supported on modern versions of iOS, including iOS 10.

iOS的现代版本支持此功能,包括iOS 10。

Another way to do it is to save an array of transaction_id values and associate these with user accounts. Depending on your needs, this might work better for you.

另一种方法是保存一系列transaction_id值并将其与用户帐户相关联。根据您的需要,这可能对您更有效。

UPD by Stafox: time-to-time original_transaction_id may changes after renew and may still the same after cancel and resubscribe.

Stafox的UPD:续订后的原始时间original_transaction_id可能会发生变化,取消和重新订阅后可能仍然相同。