Access itunes connect for product description.? - ios

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

Related

In App purchased product not found but already setup on itune connect year 2017

Hello guys I am having issue on in-app purchased' here what I have done.
First I add my product id in ituneconnect example product id "com.myweb.myappname.product1" and my bundle Identifier in my ios project is "com.myweb.myappname".
The status of my product ID is Ready to Submit but my problem is I cannot submit it because' the Save and Submit for Review button is disabled.
How to resolved this?
I used this code to tes in app purchased code but the result is always "NO product Found..".
//my bundle Identifier = com.myweb.myappname
NSURL *url = [[NSBundle mainBundle] URLForResource:#"product_ids"
withExtension:#"plist"];
NSArray *productIdentifiers = [NSArray arrayWithContentsOfURL:url];
NSString *myfirstrpodcuct = [productIdentifiers objectAtIndex:0];
NSLog(#"myfirstrpodcuct = %#",myfirstrpodcuct); //this display my product id com.myweb.myappname.product1
if([SKPaymentQueue canMakePayments]) {
SKProductsRequest *request = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObjects:myfirstrpodcuct, nil]];
request.delegate = self;
[request start];
} else {
NSLog(#"Cannot used inApp Purchased.");
}
- (void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
self.products = response.products;
if(response.products.count != 0){
NSLog(#"Product Found..");
} else {
NSLog(#"NO product Found..");
exit(0);
}
for (NSString *invalidIdentifier in response.invalidProductIdentifiers) {
// Handle any invalid product identifiers.
NSLog(#"Handle any invalid product identifiers");
}
NSLog(#"displayStoreUI");
// [self displayStoreUI]; // Custom method
}
I also tried to archived the project and submit the binary to ituneconnect. Then I used testflight to test the app but still the product not found.. any idea?

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.

In-App Purchase Product Request Method Needs Two Calls

I currently have created a series of methods that call and return In-App Purchase products that I have created. I can call the SKProductRequest without issue, I can even purchase the item and receive a successful purchase notification (SKPaymentTransactionStatePurchased).
The issue is that for whatever reason, when I initially run the app, I have to call the following methods 2 times in order to receive a non-null response from Apple:
/// In app purchases
- (IBAction)BuyProduct:(id)sender {
if ([SKPaymentQueue canMakePayments]) {
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:_productID]];
request.delegate = self;
[request start];
} else {
NSLog(#"Please enable In App Purchasing in your settings");
}
}
#pragma mark _
#pragma mark SKProductsRequestDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSArray *products = response.products;
if (products.count != 0) {
NSLog(#"Products available: %#", _product.localizedTitle);
_product = products[0];
} else {
NSLog(#"Products not found.");
}
products = response.invalidProductIdentifiers;
for (SKProduct *product in products) {
NSLog(#"Product not found: %#", product);
}
}
Every time, the first time I call the BuyProduct IBAction i receive this:
(excuse the dashes - simply clearing my personal info!)
---------- --.07.55.823 -------[2474:827710] Products available: (null)
Then the second time and onwards that I call the same IBAction button, I receive the IAP name correctly,
---------- --.08.03.142 -------[2474:827710] Products available: TEST IAP
---------- --.08.04.455 -------[2474:827710] Products available: TEST IAP
SO, I am just trying to figure out why I need to call these methods 2 times in order for Apple (or my code) to successfully return my IAP product name. If anyone could help me out I would greatly appreciate it!

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

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.

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