Autorenewable subscription in-app purchases in iphone?

Go To StackoverFlow.com

1

I have an iPhone application in which I am using Auto renewable subscriptions using MKstorekit4.1.I am successfully implemented it and I'm getting the server responses.Actually I want to use this subscription active for 1 month. I am giving value in the config.plist as 30.But when I'm testing I need to purchase again in the same day? I need that purchase to be active for 30 days. MKstorekit says they have already taken care of it with the following code.Then why I have this scenario.

-(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);        
   }
}

Can anybody help me?

2012-04-05 15:24
by hacker


2

When you are in the sandbox,one month subscription expires every 5 minutes,and after 30 minutes since first purchase it stops auto renewing,so don't get frustrated,when you notice that it doesn't auto renew anymore,or expired before you expected that.

2012-04-06 06:46
by Nikita Pestrov
for 1 month subscription we need to give the value as 30 in config plist.is that right - hacker 2012-04-06 07:09
If you publish the ap - Nikita Pestrov 2012-04-06 07:12
i didnt get u.can u pls clarrify this doubt. - hacker 2012-04-06 07:14
i have also one more doubt that the above snipet is enough for checking the auto renewal?or we want to customise it - hacker 2012-04-06 07:18
I mean, if you publish your app, yeah,you have to give value of 30 days.In my own app, i don't use MSKit,i just save the expire date that apple gives me from receipt in USerDefaults,and every launch check,if [NSDate date] is bigger than that.If so,i validate the latets receipt i saved and it tells me,if user had prolounged the subscription - Nikita Pestrov 2012-04-06 07:29
thank u so much, looking forword to u in the future also. - hacker 2012-04-06 07:32
can u look in to this http://stackoverflow.com/questions/10040276/aws-iossdk-for-s3-integration-in-iphon - hacker 2012-04-06 07:34
Really,i don't know the answer,but i think,that NSStream is what you nee - Nikita Pestrov 2012-04-06 07:49
[MKStoreManager sharedManager] isSubscriptionActive:kFeatureAId]) is not working with ios 4.3 ?Do u know why as you r a master of subscription? But in ios 5 simulator it is working fine - hacker 2012-04-06 14:27
Oh man sorry ..it was not working in device.either it is ios 5 or 4.3.But i will be successfully recieving the response from itunes server.is that due to the server change of simulator and devic - hacker 2012-04-06 15:10
Maybe it's really not active,is that possible?What do you mean by 'not working' - Nikita Pestrov 2012-04-06 15:33
i mean all functionalities that i added according to purchase is not working.but it working fine in ios5 simulator if([[MKStoreManager sharedManager] isSubscriptionActive:kFeatureAId]) { //unlock[self.view addSubview:joinn.view]} here if the subscription exists i am adding some other view. and if not some another view.fine in simulator.but in device showing only the unsubscribed view - hacker 2012-04-06 15:48
I am very much frustrated can u help m - hacker 2012-04-06 15:49
It really means,that you are not subscribed - Nikita Pestrov 2012-04-06 15:50
let us continue this discussion in chatNikita Pestrov 2012-04-06 15:50
i didnt get u i am getting the response from server with a status status = 21006 - hacker 2012-04-06 15:54
This means,that subsrcription is out of date.Come to chat - Nikita Pestrov 2012-04-06 15:57
but how it will be happening in simulato - hacker 2012-04-06 16:00
and also when i again try to by it will show u have already subscribed to thi - hacker 2012-04-06 16:01
when i got the status 0 the desired result is not happening.i was done just nothing but [MKStoreManager sharedManager] isSubscriptionActive:kFeatureAId]) - hacker 2012-04-06 17:42
then inside that i was adding a view.suprisingly it was working fine in the ios5 simulato - hacker 2012-04-06 17:44
Please move extended discussions to [chat] - Tim Post 2012-04-07 14:27
Ads