Ios6 在iOS 6和iOS 7中验证采购收据
我正在使用以下代码验证应用内购买收据:Ios6 在iOS 6和iOS 7中验证采购收据,ios6,ios7,in-app-purchase,Ios6,Ios7,In App Purchase,我正在使用以下代码验证应用内购买收据: - (void) completeTransaction:(SKPaymentTransaction*) transaction { NSData* receipt = nil; // 1. Attempt <app receipt> first (iOS 7.x) NSBundle* mainBundle = [NSBundle mainBundle]; if ([mainBundle respon
- (void) completeTransaction:(SKPaymentTransaction*) transaction
{
NSData* receipt = nil;
// 1. Attempt <app receipt> first (iOS 7.x)
NSBundle* mainBundle = [NSBundle mainBundle];
if ([mainBundle respondsToSelector:@selector(appStoreReceiptURL)]) {
NSURL* appStoreReceiptURL = [mainBundle appStoreReceiptURL]; // <- CRASH
receipt = [NSData dataWithContentsOfURL:appStoreReceiptURL];
}
// 2. Fallback to <transaction receipt> (iOS < 7.0)
if (!receipt) {
receipt = [transaction transactionReceipt];
}
// 3. Have server verify it with iTunes:
[self verifyReceipt:receipt forTransaction:transaction];
}
-(void)completeTransaction:(SKPaymentTransaction*)交易
{
NSData*接收=无;
//1.先尝试(iOS 7.x)
NSBundle*mainBundle=[NSBundle mainBundle];
if([mainBundle respondsToSelector:@selector(appStoreReceiptURL)]){
NSURL*appStoreReceiptURL=[mainBundle appStoreReceiptURL];//是,如果使用此appStoreReceiptURL方法,您应该直接检查版本号。
appStoreReceiptURL
在iOS中,使用以下代码检测此方法是否可用:
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
if(楼层(NSFoundationVersionNumber)