我只是想问是否有办法检查用户是否确实以编程方式购买了应用程序。我看到《无尽之剑 3》和其他游戏如何强制用户登录他们的苹果帐户,并以某种方式向商店核实该应用程序是否已被购买。这怎么可能以编程方式创建?我在整个网络上进行了搜索,只是为了找到如何打开 storkit View ,您可以从中购买其他应用程序或视频等...提前致谢
最佳答案
您可以尝试检查应用程序的收据并通过 AppStore 进行验证 -
NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL]; // iOS 7+, do not use respondsToSelector as it will report YES for iOS 6 too
这是Apple's documentation关于如何验证您的收据。
如果收据为 nil 或者 url 指向不存在的路径,您可能需要刷新收据。
实现 SKRequestDelegate 并检查:
NSError* err = nil;
if (![url checkResourceIsReachableAndReturnError:&err]){
SKReceiptRefreshRequest* request = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:nil];
request.delegate = self; /* or your delegate's instance here */
[request start];
}
....
-(void)requestDidFinish:(SKRequest*)request{
if([request isKindOfClass:[SKReceiptRefreshRequest class]]){
// The URL should be available now, if it's not - I guess the app is cracked
}
}
-(void)request:(SKRequest*)request didFailWithError:(NSError *)error{
; // This does not mean the app is pirated, use this to schedule the test for later.
}
我会在 Debug模式下(以及在模拟器上)禁用这些检查。
您可能想检查这个项目 - VerifyStoreReceiptiOS用于验证您的收据。
关于ios - 检查应用程序是否已购买,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27088768/