I am working on IAP first time i have not uploaded any version on app store we have included IAP in first version. i have submitted IAP Three times but still everytime we get Developer action needed status. I have created test user and working good in sandbox env. Now if i have uploaded app on store will IAP works??
Belo code got information in sandbox env now what to do for actual working means when i uplaod app on store will it work same as sandbox mode,
-(void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct = nil;
int count = [response.products count];
if (count>0) {
validProducts = response.products;
validProduct = (response.products)[0];
if ([validProduct.productIdentifier
isEqualToString:kTutorialPointProductID]) {
NSLog(#"All product title is --%#",validProduct.localizedTitle);
NSLog(#"All product prize is %#", validProduct.price);
NSLog(#"All des is %#",validProduct.localizedDescription);
NSLog(#"response products is %#", validProduct.productIdentifier);
NSLog(#"AL*****%#", validProduct);
}
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:#"Not Available"
message:#"No products to purchase"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[tmp show];
}
}
Goto iTunes connect- >Manage APPs -> Manage In app Purchase -> Select your in app purchase
Make sure the product Cleared for Sale Yes and add screenshot for review.
Make sure IN- APP Purchase Details have Proper Display Name and Description
In iTunes connect- > Manage APPs -> View Details of the app.
Below Demo Account Information (Optional)
There is IN APP PURCHASE.You need to select the appropriate in app and save before You proceed with Ready to Submit.
if your in app purchase works fine with SandBox account then it is working fine !!!
Related
I've made an iOS in-app Auto-Renewable Subscription, now I'm trying to allow users to purchase it in a React-Native app.
I've found react-native-in-app-utils, but can't seem to even load my products. I have 3 "products" (auto-renewable subscriptions) in iTunes connect, but trying to load them with:
var products = [
'com.xxxx.app.monthly',
'com.xxxx.app.6months',
'com.xxxx.app.year',
];
InAppUtils.loadProducts(products, (error, products) => {
console.log('products:', products);
});
just logs "products: []".
Digging a little deeper, I've added some additional logging to the objective-c code doing the querying, and it looks like:
NSLog(#"loading products %#", productIdentifiers);
if([SKPaymentQueue canMakePayments]){
SKProductsRequest *productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]];
productsRequest.delegate = self;
_callbacks[RCTKeyForInstance(productsRequest)] = callback;
[productsRequest start];
} else {
callback(#[#"not_available"]);
}
Then in the callback:
NSLog(#"products response %#", response.products);
products = [NSMutableArray arrayWithArray:response.products];
NSMutableArray *productsArrayForJS = [NSMutableArray array];
for(SKProduct *item in response.products) {
NSDictionary *product = #{
...
This will log "loading products" with my product ids, as expected. But then "products response ()"... empty response.
Those products are listed in iTunes connect as "Ready to Submit". And they've been added to the app info under In-App Purchases. What gives? Why aren't the products showing up?
Looks like it was an administrative issue, not a technical one. Project Manager hadn't put through the paid app agreement.
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.
Our app provides in app purchases to apple hosted extra content which the user downloads, but some users are reporting problems with the download.
It seems to fail halfway through, alert the user and resets all buttons etc to allow the user to buy again (for free as they have already purchased). If the user then tries to re buy or restore purchases in the app it still fails. The following code is what handles a failed state.
-(void) paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads{
for (SKDownload *download in downloads){
switch (download.downloadState){
case SKDownloadStateActive:{
//code removed for post
break;
}
case SKDownloadStateCancelled:{ break; }
case SKDownloadStateFailed:
{
//log the error
NSLog(#"Transaction error: %#", download.transaction.error.localizedDescription);
//let the user know
[[[UIAlertView alloc] initWithTitle:#"Error!" message:[NSString stringWithFormat:#"%# download failed, please try again later", download.contentIdentifier] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
//post notification - caught in view controller for updating buy buttons etc
[[NSNotificationCenter defaultCenter] postNotificationName:IAPHelperDownloadFailedNotification object:download userInfo:nil];
// This should delete the download assets from the Cache folder.
NSError* error = nil;
[[NSFileManager defaultManager] removeItemAtURL:download.contentURL error:&error];
if(error){
//
}
//finish the transaction
[[SKPaymentQueue defaultQueue] finishTransaction:download.transaction];
break;
}
case SKDownloadStateFinished:{
//code removed for post
break;
}
case SKDownloadStatePaused:{
break;
}
case SKDownloadStateWaiting:{
break;
}
}
}
I've looked around stack overflow and elsewhere and what little examples I can find on in app purchases all do the same as above. Any help or info would be great.
I got similar problem and just found a possible resolution in Apple's FAQ on IAP:
Q: How do I resolve the "You've already purchased this In-App Purchase but it hasn't been downloaded." error message?
A: You are getting the "You've already purchased this In-App Purchase but it hasn't been downloaded." error message because you did not call SKPaymentQueue 's finishTransaction:method in your application. Calling finishTransaction: allows you to remove a transaction from the payment queue.
I think I will ask my IAP engine to check whether there is any IAP is being processed when app exits(my problem occurs when user stopped the app while downloading), if yes, calls finishTransaction:.
Hope it helps.
I integrated the In-App purchase for my app. I also set the purchase on itunes & shows me status as Ready to Submit.
But I want to test it without submitting the binary.
So, Is there is another set required for Sandbox In-App testing?
My code:
[[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success)
{
[appDel dismissGlobalHUD];
NSMutableArray *arrProductsBuyHeart = [[NSMutableArray alloc]init];
NSMutableArray *arrTemp = [[NSMutableArray alloc]init];
for (SKProduct *Sss in products)
{
NSString *string = Sss.productIdentifier;//#"hello bla bla";
if ([string rangeOfString:#"com.xxxxxxxx.buy"].location == NSNotFound) {
//NSLog(#"string does not contain Buy");
} else {
NSMutableDictionary *dictprod = [NSMutableDictionary dictionary];
[dictprod setObject:Sss.productIdentifier forKey:#"ProductIdentifier"];
[dictprod setObject:Sss.price forKey:#"ProductPrice"];
[dictprod setObject:Sss.localizedTitle forKey:#"ProductTitle"];
[arrTemp addObject:dictprod];
}
}
if (arrTemp.count > 0)
{
NSSortDescriptor *brandDescriptor = [[NSSortDescriptor alloc] initWithKey:#"ProductPrice" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:brandDescriptor];
arrProductsBuyHeart = [NSMutableArray arrayWithArray:[arrTemp sortedArrayUsingDescriptors:sortDescriptors]];
//NSLog(#"My products > %#",arrProductsBuyHeart);
for (int i = 0;i<[arrProductsBuyHeart count];i++)
{
NSString *strProductID = [[NSString stringWithFormat:#"%#",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:#"ProductIdentifier"]]RemoveNull];
NSString *strPrice = [[NSString stringWithFormat:#"$%#",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:#"ProductPrice"]]RemoveNull];
if ([strProductID isEqualToString:InApp200Coins])
{
[btn1KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp600Coins])
{
[btn2KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp900Coins])
{
[btn4KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp2KCoins])
{
[btn10KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp4KCoins])
{
[btn50KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
}
}
else
DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found.");
}
else
{
[appDel dismissGlobalHUD];
DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found.");
}
}];
}
Output DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found."); & Not able to get Product List.
Help me to solve this.
First of you can create app in itunes connect.
-add product in In-app purchase.
-then after itunes home page you can add test user click on manage user.
after add you can remove your apple account in your device then login with test user
after login you can test in-App purchase in Sandbox mode.
Create a test user account in iTunes Connect, as described in “Creating Test User Accounts” in iTunes Connect Developer Guide.
On a development iOS device, sign out of the App Store in Settings. Then build and run your app from Xcode.
On a development OS X device, sign out of the Mac App Store. Then build your app in Xcode and launch it from the Finder.
Use your app to make an in-app purchase. When prompted to sign in to the App Store, use your test account. Note that the text “[Environment: Sandbox]” appears as part of the prompt, indicating that you’re connected to the test environment.
If the text “[Environment: Sandbox]” doesn’t appear, you’re using the production environment. Make sure you’re running a development-signed build of your app. Production-signed builds use the production environment.
Important: Don’t use your test user account to sign in to the production environment. If you do, the test user account becomes invalid and can no longer be used.
I keep getting invalid product identifiers as a return from in app purchase product requests.
I've checked the following:
Checked provisioning profiles, deleted and re-made several times...
Checked product identifiers against products in itunesconnect (uk.co.companyname.appname.product_name).
Deleted app and provisions from phone and re installed.
Logged out of app store on phone.
Checked my code signing (signed as iPhone Developer (with uk.co.companyname.appname as identifier)
Made sure app identifier is in info.plist correctly.
Submitted and rejected app binary.
Running on phone, not simulator.
This is my code for fetching products:
- (void)loadProducts
{
NSSet *productIdentifiers = [NSSet setWithObjects:uk.co.companyname.appname.product_name, uk.co.companyname.appname.product_name2, uk.co.companyname.appname.product_name3, nil];
for(NSString *pk in productIdentifiers) NSLog(#"%#", pk);
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(#"products: %d", [response.products count]);
NSLog(#"invalidProductIdentifiers: %d", [response.invalidProductIdentifiers count]);
}
and I get:
products: 0
invalidProductIdentifiers: 9