gpt4 book ai didi

ios - mainBundle 上的 appStoreReceiptURL 始终返回 nil

转载 作者:行者123 更新时间:2023-11-29 05:43:27 24 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/56354054/

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