gpt4 book ai didi

ios - mainBundle 上的 appStoreReceiptURL 总是返回 nil

转载 作者:可可西里 更新时间:2023-11-01 05:01:00 26 4
gpt4 key购买 nike

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

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

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

有人知道为什么吗?

最佳答案

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

-(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];
}
}
}

`

关于ios - mainBundle 上的 appStoreReceiptURL 总是返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20027322/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com