IOS in-app purchases stopped working suddenly, fetching null identifiers - ios

My in-app purchases were working until yesterday and today I am submitting my app for review. The only change that I made is that in the app page in the iTunes, I connected my app (by checking) with the in-app purchases.
From that time, every time I try in my debug app to buy something with my test account, I am getting this error:
NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
I have already:
re-installed my app
logged out from my store and used again my test account
but today nothing seems to work. The exact same code was working perfect yesterday, with the same test account.
May it be because I did this change in itunes? I am worrying what would happen when my app gets approved and goes online.
Any help is greatly appreciated.
EDIT:
The problem is that the array _products stays nil.
- (void)reload {
_products = nil;
NSLog(#"reload is called");
[[VimaIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success) {
_products = products;
NSLog(#"Success from AppStore");
}
}];
for (SKProduct* product in _products) {
NSLog(#"In-app item:%#",product.localizedTitle);
}
}
The Success log message is never called. Yesterday I had no problem, with the same code.
EDIT:
after a lot of tries, it works. Without changing anything. It seems that the server takes a lot of time to respond back. However, I cannot buy the product since I get an "cannot connect to itunes". Why that might happen?
EDIT2:
In other tries, the problem seems to be in this code:
pragma mark - SKProductsRequestDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
for (SKProduct * skProduct in skProducts) {
NSLog(#"Found product: %# %# %0.2f",
skProduct.productIdentifier,
skProduct.localizedTitle,
skProduct.price.floatValue);
}
_completionHandler(YES, skProducts);
_completionHandler = nil;
}
after the for loop. Especially, I get a BAD_ACCESS in line: _completionHandler(YES, skProducts);

A problem with the Xcode 5 simulator has been reported but not fixed. See this post describing the situation.

Actually the problem was that during these days the whole Apple Dev Center was down, so the above code is working for anyone else who is looking for an example.

Related

RMStore In App Purchase Unknown Product Identifier

I have spent all day trying to get an in app purchase to work in my app, and everything that I have tried to make it work results in a 'Unkown Product Identifier' response from RMStore. I have tried everything on this list: http://troybrant.net/blog/2010/01/invalid-product-ids/
My Code is:
if ([RMStore canMakePayments]) {
_products = #[#"com.afterdark.afterdark.usersaleslisting"];
[[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
NSLog(#"Request Success");
NSString *productID = _products[0];
SKProduct *product = [[RMStore defaultStore] productForIdentifier:productID];
NSLog(#"IAP ID: %#",productID);
NSLog(#"IAP TITLE: %#",product.localizedTitle);
NSLog(#"IAP PRICE: %#",[RMStore localizedPriceOfProduct:product]);
[[RMStore defaultStore] addPayment:productID success:^(SKPaymentTransaction *transaction) {
NSLog(#"Payment Succes");
} failure:^(SKPaymentTransaction *transaction, NSError *error) {
NSLog(#"Payment Failed: %#",error.localizedDescription);
}];
} failure:^(NSError *error) {
NSLog(#"Request Failed: %#",error.localizedDescription);
}];
}
Itunes Connect - In App Purchases:
Xcode - In App Purchases Capability
I have completely run out of ideas of how to get this to work, anyone have any ideas? Any help will be appreciated. Thank you in advance.
So, I have finally got this working. I contacted apple and it turns out the only reason it wasn't working is because something had gone wrong on their servers when I created the IAP in iTunes Connect, they promptly resolved the issue.

How to test In-app purchase in Sandbox mode iOS?

Am new to In-app purchase integration in iOS application. I have done the coding in the project level and I have created a Sandbox user in iTunes Connect. I read many tutorials and Apple Document to test the In-App purchase in DEV mode.
As per the document I have removed the APPLE ID from iPad Settings and launched the app from Xcode. But, I didn't received the Account Alert from the app. Also, my products are returning empty in SKProductRequest delegate method didReceiveResponse. I have posted my code for your reference. Can you please help me on this? Am working since last two days. Please help me. Thanks in advance.
- (void) getAvailProducts
{
NSLog(#"Fetching Available Products");
NSSet *productIdentifiers = [NSSet setWithObjects:#"com.test.testios.monthly", #"com.test.testios.yearly" ,nil];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
//SKProduct *validProduct = nil;
DebugLog(#"\n Products: %#", response.products);
NSUInteger count = [response.products count];
NSLog(#"Request Count: %lu", (unsigned long)count);
if (count > 0)
{
self.validatedProducts = response.products;
DebugLog(#“\n Products: %#", response.products);
self.validationCheck = TRUE;
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
// Check subscription
}
else
{
// No products found….
}
}
Also, I tried with "monthly and yearly" instead of "com.test.testios.monthly and com.test.testios.yearly". But, no results.
Edit: Am getting the mentioned ProductIds are invalid in the following code,
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(#"Invalid product id: %#" , invalidProductId);
}
Thank you all.
Fixed the issue and tested the In-App purchase in Sandbox environment. Following items fixed my issue,
1. iTunes Agreement was not accepted.
2. Tax and Payment details was not added.
3. Added correct Product Identifier in project.

Issue with InApp purchase in Sandbox mode: SKProductsRequest delegate returns inconsistent response

When requesting for in-app auto renewable subscription products from apple, I sometimes get valid products but most of the times I get invalidProductIdentifiers in SKProductsResponse object. I wrote a small piece of code to verify this inconsistency in response:
-(void)viewDidAppear:(BOOL)animated{
[self getProductsFromApple];
}
-(void)getProductsFromApple{
SKProductsRequest *_productRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:#"2"]];
[_productRequest setDelegate:self];
[_productRequest start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
NSLog(#"Invalid %#", response.invalidProductIdentifiers);
NSLog(#"Valid %#", response.products);
if (response.invalidProductIdentifiers && [response.invalidProductIdentifiers isKindOfClass:[NSArray class]] && response.invalidProductIdentifiers.count) {
[self getProductsFromApple];
}
}
This sometimes succeeds after n calls to apple server.Our team has escalated the issue to apple, we are waiting for there response.
Has anyone faced this issue, kindly suggest how you were able to test in-apps payment ?

Access itunes connect for product description.?

I developed one in app purchase application by using this tutorial
Ray wenderlich
Its working nicely.But i need to get the product description from the itunes connect at loading time of app .iam able to display the same in in app purchase page using following code but not able to do the same in loading time?
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
SKProduct * product = (SKProduct *)skProducts[0];
NSLog(#"naveen -->%#",product.localizedDescription); //will give description of product
for (SKProduct * skProduct in skProducts) {
NSLog(#"Found product: %# %# %0.2f",
skProduct.productIdentifier,
skProduct.localizedTitle,
skProduct.price.floatValue);
}
_completionHandler(YES, skProducts);
_completionHandler = nil;
}
i got the answer ,thanks for all.
The reason is when app lauch we have to call a methode didfinishload in appdelegate.m

InApp purchase on iOS 5 vs iOS 6

I've been testing the new version of my app, which will include an in-app purchase in the next update, for one month.
Everything worked fine both on iOS 6 and 5, but recently I'm starting to get an empty SKProducts array back from the requests I make from iOS 5.
The strange thing is that, by executing the same application on iOS 6, I get the correct products array with all the elements I've set up in iTunes connect.
Anyone having the same problem? What can it be?
You used Jail Break device to test, didnt u?
You can add this to productsRequest method to check the invalid identifier
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
NSLog(#"Number of products: %d", [skProducts count]);
for (SKProduct * skProduct in skProducts) {
NSLog(#"Found product: %# %# %0.2f",
skProduct.productIdentifier,
skProduct.localizedTitle,
skProduct.price.floatValue);
}
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(#"Invalid product id: %#" , invalidProductId);
}
_completionHandler(YES, skProducts);
_completionHandler = nil;
}
Follow this post
http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/

Resources