How to add some player message on apple purchases?

Hi,

I need to add some message when apple purchase begin. and get it back when purchase success.

Because I need it to verify the player is who. for example the player change the account and the purchase

process break for some reason.

So how to do it ? thanks.

when I look for the google. so the question is How to use applicationUsername in iap. where can I find this value in unity iap.

Welcome to the forum! IAP doesn’t use the application username. And can you be more specific, “change the account”, you mean resets their phone with a new user profile and associated credit card? And begin-to-end often takes only a second or two, probably not enough time to display a message? Is IAP working for you otherwise? But if you really want a message, just show it on the initial purchase button click. The purchase will be complete when ProcessPurchase is called.

Hi, my question is, how to pass the user identity (such as user name) along with the IAP request?

And use SKMutablePayment.applicationUsername can save and read back private account username in native IOS.

save:

SKMutablePayment* payment = [SKMutablePayment paymentWithProduct:product];
payment.applicationUsername = @“my_username_1001”;

and send it to ios purchases …


read:

-(void)paymentQueue:(SKPaymentQueue )queue updatedTransactions:(NSArray )transactions
{
for (SKPaymentTransaction
trans in transactions) {
switch (trans.transactionState) {

case SKPaymentTransactionStatePurchased:
// got private user account here
NSString
applicationUsername = [[trans payment] applicationUsername];
break;

}
}
}


So Is there some way to use it in unity iap?

This is a example .

There are two different game characters in a single iPhone device, we call it A and B.

First, app user login as A, he perform an IAP action, the A logout without the purchase completed.

Then, app user login as B, then purchase finish event arrival, this is the problem, how to judge the receipt belongs to A, not B.

You could try SetObfuscatedAccountId(String) https://docs.unity3d.com/Packages/com.unity.purchasing@3.0/api/UnityEngine.Purchasing.IGooglePlayStoreExtensions.html

But I need to use it in IOS. So is there some thing like it ?

Not to my knowledge. You could use PlayerPrefs to track purchases by user, but it’s not entirely secure.