iphone中的自动更新订阅应用内购买?
问题描述:
我有一个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);
}
}
任何人都可以帮助我吗?
答
当您在沙盒中时,每5分钟就会有一个月的订阅过期,第一次购买后的30分钟后会停止自动更新,所以不要感到沮丧,当您发现它不再自动更新时,或在您预期之前过期。
对于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