[英]Validating Receipts With the App Store from my server
我正在使用以下代碼進行收據驗證。
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt) {
/* No local receipt -- handle the error. */
}
/* ... Send the receipt data to your server ... */
每次調用不同的收據ID時,在哪里可以在代碼中添加此代碼,以及何時調用此代碼。 任何人請幫助我。
創建一個單獨的類文件並在該類中添加一個方法(或者您可以在AppDelegate.m文件中編寫此方法)
-(void)yourMethodName
{
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt) {
/* No local receipt -- handle the error. */
}
/* ... Send the receipt data to your server ... */
}
要調用此方法,請從AppDelegate.m類的以下代碼中編寫要調用的位置。
[[AppDelegate sharedAppdelegate] yourMethodName];
或其他班級
[className yourMethodName];
嘗試這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.