1
我有一個iPhone應用程序,我正在使用自動更新訂閱使用MKstorekit4.1.I我成功地實現了它,我得到了服務器響應。實際上我想使用此訂閱活動1個月。我將config.plist中的值設爲30.但是當我測試時,我需要在同一天再次購買?我需要這筆購買活動30天。 MKstorekit說他們已經用下面的代碼來處理它了。那麼爲什麼我有這種情況。iphone中的自動更新訂閱應用內購買?
-(BOOL) isSubscriptionActive
{
if([[self.verifiedReceiptDictionary objectForKey:@"receipt"] objectForKey:@"expires_date"]){
NSLog(@"%@",self.verifiedReceiptDictionary);
NSTimeInterval expiresDate = [[[self.verifiedReceiptDictionary objectForKey:@"receipt"] objectForKey:@"expires_date"] doubleValue]/1000.0;
NSLog(@"%f",expiresDate);
NSLog(@"%f",[[NSDate date] timeIntervalSince1970]);
return expiresDate > [[NSDate date] timeIntervalSince1970];
}else{
NSString *purchasedDateString = [[self.verifiedReceiptDictionary objectForKey:@"receipt"] objectForKey:@"purchase_date"];
if(!purchasedDateString) {
NSLog(@"Receipt Dictionary from Apple Server is invalid: %@", verifiedReceiptDictionary);
return NO;
}
NSLog(@"%@",purchasedDateString);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
//2011-07-03 05:31:55 Etc/GMT
purchasedDateString = [purchasedDateString stringByReplacingOccurrencesOfString:@" Etc/GMT" withString:@""];
NSLocale *POSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[df setLocale:POSIXLocale];
[df setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *purchasedDate = [df dateFromString: purchasedDateString];
int numberOfDays = [purchasedDate timeIntervalSinceNow]/(-86400.0);
NSLog(@"%@",purchasedDate);
NSLog(@"%@",numberOfDays);
return (self.subscriptionDays > numberOfDays);
}
}
任何人都可以幫助我嗎?
對於1個月的訂閱,我們需要在config plist.is中給出30的值,對嗎? – hacker 2012-04-06 07:09:01
如果你發佈的應用程序 – 2012-04-06 07:12:58
我沒有得到你可以解釋這個疑問.. – hacker 2012-04-06 07:14:29