I am new to IOS. currently working on in app purchase implementation in my newsstand app.i have implemented auto renewable subscription in my newsstand app.how can i check in app purchase auto renewable subscription is valid or not?
Asked
Active
Viewed 1,750 times
1
-
This link https://stackoverflow.com/questions/22680059/auto-renewable-subscription-in-ios7/45220204#45220204 might help you. – Arun Jain Jul 27 '17 at 12:46
2 Answers
2
When you create the subscription you need to store the receipt object. You can use the receipt to determine if the subscription it represents is valid.
I'm using CargoBay (https://github.com/mattt/CargoBay) to help with StoreKit processing. It has a method:
[[CargoBay sharedManager] verifyTransaction:transaction password:nil success:^(NSDictionary *receipt) {
NSLog(@"Receipt: %@", receipt);
} failure:^(NSError *error) {
NSLog(@"Error %d (%@)", [error code], [error localizedDescription]);
}];

Richard Brown
- 11,346
- 4
- 32
- 43
0
Today, I have trouble with this problem. Follow Apple doc here, I used this way to check subscription is expired or not.
This is my code in Objective-C.
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:resData options:0 error:&error];
// this is response from AppStore
NSDictionary *dictLatestReceiptsInfo = jsonResponse[@"latest_receipt_info"];
long long int expirationDateMs = [[dictLatestReceiptsInfo valueForKeyPath:@"@max.expires_date_ms"] longLongValue];
long long requestDateMs = [jsonResponse[@"receipt"][@"request_date_ms"] longLongValue];
isValidReceipt = [[jsonResponse objectForKey:@"status"] integerValue] == 0 && (expirationDateMs > requestDateMs);
Hope this help.

Clover03ti05
- 401
- 1
- 4
- 11