mainBundle上的appStoreReceiptURL总是返回nil

编程入门 行业动态 更新时间:2024-10-25 15:30:07
本文介绍了mainBundle上的appStoreReceiptURL总是返回nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此方法appStoreReceiptURL是SKPaymentTransaction上已弃用的transactionReceipt方法的替代品。而且每个人都说只是使用这个调用:

This method appStoreReceiptURL is the replacement for the deprecated transactionReceipt method on SKPaymentTransaction. And everyone says to just use this call instead:

NSURL *theURL = [[NSBundle mainBundle] appStoreReceiptURL];

如果有收据,这应该会返回一个收据。但对我来说没有一个,因为这个值是零,而且据我所知,它不应该是。我在iOS 7上运行并且已经完成了一些应用内购买(设备上的沙箱)。现在我正在尝试添加另一个应用内购买,自动续订订阅,我需要深入了解收据以获取订阅到期日期。但是我无法通过这个简单的步骤,因为价值总是为零。

This is supposed to return a url to a receipt if there is one. But for me there isn't one, as this value is nil, and as far as I can tell it shouldn't be. I'm running on iOS 7 and have done a few in-app purchases (sandbox on the device). Now I'm trying to add another in-app purchase, an auto-renewing subscription, and I need to dig into the receipt to get the subscription expiration date. But I can't get past this simple step because the value is simply always nil.

有谁知道为什么?

推荐答案

有点晚了,但它可能对某人有用:

A bit late, but it may be of use to someone:

-(void) someMethod { NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL]; if ([[NSFileManager defaultManager] fileExistsAtPath:[receiptUrl path]]) { NSData *ios7ReceiptData = [NSData dataWithContentsOfURL:receiptUrl]; //Do stuff } else { NSLog(@"iOS 7 AppReceipt not found %@, refreshing...",iapID); SKReceiptRefreshRequest *refreshReceiptRequest = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{}]; refreshReceiptRequest.delegate = self; [refreshReceiptRequest start]; } } - (void)requestDidFinish:(SKRequest *)request { if([request isKindOfClass:[SKReceiptRefreshRequest class]]) { //SKReceiptRefreshRequest NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL]; if ([[NSFileManager defaultManager] fileExistsAtPath:[receiptUrl path]]) { NSLog(@"App Receipt exists"); //Do stuff } else { NSLog(@"Receipt request done but there is no receipt"); // This can happen if the user cancels the login screen for the store. // If we get here it means there is no receipt and an attempt to get it failed because the user cancelled the login. //[self trackFailedAttempt]; } } }

`

更多推荐

mainBundle上的appStoreReceiptURL总是返回nil

本文发布于:2023-10-19 19:19:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:mainBundle   appStoreReceiptURL   nil

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!