appStoreReceiptURL を使用して、誰かが購入したアプリのバージョンを確認したいと考えています。これを文字列にするにはどうすればよいですか?
ストアからアプリをダウンロードし、Xcode から新しいバージョンのアプリを実行して、これをテストしています。これが私が試したことです:
NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL];
NSLog(@"receiptUrl %@",[receiptUrl path]);
if ([[NSFileManager defaultManager] fileExistsAtPath:[receiptUrl path]]) {
NSLog(@"exists");
NSError *error;
NSString *receiptString = [[NSString alloc] initWithContentsOfFile:[receiptUrl path] encoding:NSUTF8StringEncoding error:&error];
if (receiptString == nil) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Receipt: %@",receiptString);
}
} else {
NSLog(@"does not exist");
}
これは私が得るものです:
receiptUrl /var/mobile/Applications/E612F261-2D30-416E-BF82-F24xxxx8860/StoreKit/receipt
exists
Error: The operation couldn’t be completed. (Cocoa error 261.)