2013-02-19 2 views
1

IOS에 익숙하지 않습니다. 현재 내 뉴스 스탠드 app.i의 앱 구매 구현에서 내 신문 가판대 앱에서 자동 갱신 구독을 구현했습니다. 앱 구매시 자동 갱신 구독이 유효한지 여부를 확인할 수 있습니까?체크인 앱 구매 자동 갱신 구독이 유효합니다

+0

이 링크 https://stackoverflow.com/questions/22680059/auto-renewable-subscription-in-ios7/45220204#45220204 도움이 될 수 있습니다. –

답변

2

구독을 만들 때 영수증 개체를 저장해야합니다. 영수증을 사용하여 그것이 나타내는 구독이 유효한지 확인할 수 있습니다.

저는 StoreKit 처리를 돕기 위해 CargoBay (https://github.com/mattt/CargoBay)를 사용하고 있습니다. 메서드가 있습니다 :

[[CargoBay sharedManager] verifyTransaction:transaction password:nil success:^(NSDictionary *receipt) { 
    NSLog(@"Receipt: %@", receipt); 
} failure:^(NSError *error) { 
    NSLog(@"Error %d (%@)", [error code], [error localizedDescription]); 
}]; 
0

오늘이 문제가 생깁니다. 여기 Apple doc을 따르십시오.이 방법으로 구독이 만료되었는지 확인합니다.

이것은 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); 

희망 도움말.

관련 문제