0

I have one speedometer app, in which 2 features are enabled by adding them to in-app purchase. Everything works fine, I have followed http://www.raywenderlich.com/2797/introduction-to-in-app-purchases

Both of the features to be enabled are non-consumable. The problem is that while I am testing this and adding test account and password, I am getting same alert view all the time - "You have already purchased this but it hasn't been downloaded.Tap OK to download it now"

[Environment: Sandbox]

Why I am getting same alert view all the time? And the feature is just to enable HUD functionality and remove ads; so nothing to download from server. And I am not able to make out if the transaction is completed or not because it is not even calling finish transaction method and just gives the same alert.

Gunther Struyf
  • 11,158
  • 2
  • 34
  • 58
David Shah
  • 13
  • 5

2 Answers2

1

I run through this tutorial and also observe this alert view. I don't think this is any issue since you have probably set-up a test account the app store. Apple store will notify you if you have purchased this item already which you probably did if you have run your app and tested the purchase functionality multiple times. This is really the part done by apple store so you don't have any handle on this.

You should received though after this alert a notification that the transaction has been completed. Make sure you have added this method:

 [[SKPaymentQueue defaultQueue] addTransactionObserver:[InAppRageIAPHelper sharedHelper]];

in your didFinishLaunchingWithOptions method of your app delegate

tiguero
  • 11,477
  • 5
  • 43
  • 61
  • Thanks @tiguero,So you mean I am on track,It's not issue?And Yes I am using one test account from the day i started this testing for my in app purchase,So I tried using another test account in the same device which i used earlier so still gives me same alert.is it because it's already done in that device?And How should I enable this feature of in app purchase?If i want to enable HUD when user clicks buy button for enable HUD in my settings?? – David Shah Aug 16 '12 at 09:17
  • Asking you because I am getting both my identifiers as not purchased when product loads..I am talking about this for (NSString * productIdentifier in _productIdentifiers) { BOOL productPurchased = [[NSUserDefaults standardUserDefaults] boolForKey:productIdentifier]; if (productPurchased) { [purchasedProducts addObject:productIdentifier]; NSLog(@"Previously purchased: %@", productIdentifier); } NSLog(@"Not purchased: %@", productIdentifier); } self.purchasedProducts = purchasedProducts; – David Shah Aug 16 '12 at 09:18
  • can you specify what kind of content you want to enable in the in-app purchase? in the tut it is only in-app content. Make sure u have read the official doc to get an understanding of it: https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/APIOverview/OverviewoftheStoreKitAPI.html#//apple_ref/doc/uid/TP40008267-CH100-SW1 – tiguero Aug 16 '12 at 09:38
  • there are two functionalities 1)Enable HUD(mirror view for speedometer)and 2)Remove ads So basically user can enable both of this functionality/feature by buying in app purchase for this..So as you said I checked for purchased items but every time it is giving me identifier for remove ads as purchased item...and Enable HUD as not purchased items...And when I try to buy/test Enable HUD then it gives me same alert view that it is purchased [Environment : Sandbox] – David Shah Aug 16 '12 at 09:51
  • also i just figure out you can reset sandbox in-app purchase here: http://stackoverflow.com/questions/7604578/how-can-i-reset-sandboxed-in-app-purchases-on-ios-for-testing – tiguero Aug 16 '12 at 10:13
  • which content did you successfully purchased in sandbox? (meaning you received a notification of the transaction being completed). If it was completed for "Enable HUD" it should be seen as purchased in your default setting. Did you change your productId for the "Enable HUD" at some point? – tiguero Aug 16 '12 at 10:14
  • i am getting RemoveAds as previously purchases item but EnableHUD as not purchased item even i am trying to purchase and it gives me alert already purchases so not getting why showing so..And yes in iTunes I have edited the company name identifiers in between as it was different than the actual company name in my appId so yes i actually deleted those in app purchase in iTunes and made new .. – David Shah Aug 16 '12 at 10:33
  • And yes as you suggested for resetting sandbox in app purchase...will it require any framework to be added?As it is not finding MKStoreManager – David Shah Aug 16 '12 at 10:34
  • Sorry MKStoreManager is part of MKStoreKit(https://github.com/MugunthKumar/MKStoreKit#readme) which is an external lib – tiguero Aug 16 '12 at 10:55
  • thanks mate for your responses.All I get is some of very good references and all,but my problem is not soled 100% yet,as i told i am getting RemoveAds as previously purchases item but EnableHUD as not purchased item even i am trying to purchase and it gives me alert already purchases so not getting why showing so..And yes in iTunes I have edited the company name identifiers in between as it was different than the actual company name in my appId so yes i actually deleted those in app purchase in iTunes and made new . – David Shah Aug 16 '12 at 12:12
  • I bet EnabledHUD is flag with purchased in your userdefault for your primary productId. – tiguero Aug 16 '12 at 13:04
  • BOOL productPurchased = [[NSUserDefaults standardUserDefaults] boolForKey:product.productIdentifier]; I always check this before I try to buy ..And Now I deleted/uninstalled my app from iPhone and again installed and debugged and I am getting false for both the identifiers(EnableHUD and RemoveAds)..Obviously it will give me false for both as i have uninstalled app an again installed..But when I buy both products it shows already purchased alert..So thing is that both of the functionality are purchased according to alert shown but flags are reset..what to do – David Shah Aug 17 '12 at 04:22
  • Oh how surprising! come on your flags will be set properly at the end of the purchase...did u understand the tuts of Ray Wenderlich??? Copy past is not your friends in the world of programming. – tiguero Aug 17 '12 at 08:57
  • @tiguero..Thanks bro..I am done with my issues..Actually the non-consumable items were not restoring because of some network problem..Now I am able to restore previous transaction after reinstalling app and using that test iTunes id and password..So overall I am done with it..I check for nsuserdefault flags and if they meet true then only I allow user to enable HUD and removed ads and showing them that yes these 2 in-app purchases are already purchased..Thnks again..:) – David Shah Aug 17 '12 at 08:57
  • at least accept my answer and upvote it...you have accepted no answers so far you won't get such help if you pursue this path – tiguero Aug 17 '12 at 08:59
  • Bro...Just look at it...I have already done with it...See..I have marked it as accepted...Thanks :) And I can not up vote as my reputation is not so good as I am just new over here.. – David Shah Aug 17 '12 at 09:02
0

Use different product Id on item purchase:

-(void)buyCoinPack_1
{
          SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:self.currentProductId_1]]; 

            request.delegate = self;  
            [request start]; 
}


-(void)buyCoinPack_2
{
          SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:self.currentProductId_2]]; 

            request.delegate = self;  
            [request start]; 
}
Guru
  • 21,652
  • 10
  • 63
  • 102