In-App Purchase doesn't work - iphone

I want to add in-app purchases to my app, but I can't make it work. I'm using MKStoreKit 4.2.
Here is the buying code:
- (IBAction)onPayButtonPressed:(id)sender {
[[MKStoreManager sharedManager] buyFeature:#"com.flowrower.TestApp.0.99.item"
onComplete:^(NSString* purchasedFeature, NSData* receiptData)
{
NSLog(#"Purchased: %#", purchasedFeature);
}
onCancelled:^
{
NSLog(#"Cancelled");
}];
NSLog (#"END");
}
In output I'm always getting "END" only. So buyFeature doesn't work at all.
Testing on iPhone 4S with iOS 6.0.
Using Provision Profile with In-App Purchases support.
There is Product ID "com.flowrower.TestApp.0.99.item" in iTunes Connect with status "Ready to submit"
This product is consumble and I have added it to MKSoreKitConfigs.plist
Everything's OK with Contacts, Bank and Taxes in iTunes Connect
Logged off from iTunes and App Store on my device.
Getting this message at app start: "NSUbiquitousKeyValueStore error: user.TestApp has no valid com.apple.developer.ubiquity-kvstore-identifier entitlement". I don't know is it related or not.

if its not approved, you need to test in the sandbox. I don't know MKStoreKit but I think you need an adhoc certificate!?

The problem was with iOS 6. 12 days ago new version of MKStoreKit released and it work like a charm in iOS 6. Thanks guys.

Related

NSUserDefaults boolForKey strange behaviour on real phone

My application is approved and ready to sale in appstore today. I downloaded it from appstore immediately but when I open my application there is no ads in my application. I dont understand anything.
In my code if user buy inapp item I set the value of userdefault to TRUE.
So when application starts Im checking this userdefaults. If it is TRUE I dont show any ads , if not I call ads api.
this is part of inapp purchasing area :
if ([productId isEqualToString:#"dontshowads"])
{
//user bought inapp item. so I must remove advertorials.
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:#"aldimi_lite_reklamikaldirma_099"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
and this is viewwillappear area :
BOOL appin_reklamkaldirmaalindimi = [[NSUserDefaults standardUserDefaults] boolForKey:#"aldimi_lite_reklamikaldirma_099"];
NSLog(#"appin_reklamkaldirmaalindimi :%d",appin_reklamkaldirmaalindimi);
if (!appin_reklamkaldirmaalindimi)
{
NSLog(#"showing ads");
}
else {
NSLog(#"no ads. user bought inapp item");
}
When I run my application in simulator everything is fine. (I deleted it first in simulator and re build it)
Console gives this logs:
appin_reklamkaldirmaalindimi : 0
showing ads
When I run my application in my real phone everything is fine also. (I deleted it first in my phone and re build it)
Console gives this logs:
appin_reklamkaldirmaalindimi : 0
showing ads
But when I run my application which is downloaded from appstore everything is different.
Console gives this logs:
appin_reklamkaldirmaalindimi : 0
no ads. user bought inapp item
I tried to download and check the situation in my friends phone . Everything is the same. So it is not about my phone.
how can it possible ? I thought one hour and I cant find any explanation to this situation ...
The only explanation for such a weird phenomenon is that the code which you submitted to the App Store is in some way corrupted or different than the code which you tested by building off your computer. The only way to fix this problem would be to resubmit your application to the App Store.
The only other possibility I can think of is that your app has some VERY poor and incorrect memory-access tendencies, such that part of your executable code or stack somehow gets over-written before running your ad logic.

SFProductsRequest always returning zero

I'm trying to implement in app purchases in a free application.
I have created a productd id "test1" within the in app purchases manager in itunes connect portal.
When I make the product request in the following way:
- (id)init {
NSSet *productIdentifiers = [NSSet setWithObjects:
#"test1",
nil];
if ((self = [self initWithProductIdentifiers:productIdentifiers])) {
}
return self;
}
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers
{
if ((self = [super init]))
{
// Store product identifiers
_productIdentifiers = [productIdentifiers retain];
// Check for previously purchased products
NSMutableSet * purchasedProducts = [NSMutableSet set];
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;
}
return self;
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Received products results...");
self.products = response.products;
self.request = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products];
NSLog(#"%d",[self.products count]);
NSEnumerator *e = [self.products objectEnumerator];
id object;
while(object=[e nextObject])
{
NSLog(#"item");
NSLog(#"%s",(char*)object);
}
}
- (void)requestProducts {
self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers] autorelease];
_request.delegate = self;
[_request start];
}
The response is always 0. I don't understand what am I doing wrong. This code came from a tutorial. The documentation regarding in app purchases tend to be quite confusing and the whole process in itunes connect doesnt give me confidence.
I thought the application needed to be online for sale for in app purchases to be working. However, I decided not to included in app purchases, but let the in app purchase in itunes connect for review. During the review process, the application was rejected because it should be working with the in app purchases for testing.
But how do I test in app purchases if the product listing comes always at zero?
If someone with more experience could give me an advice on this, since i'm already getting crazy with it!
Thanks,
With my best regards,
Nuno
The most coherent solution I found to this problem was this checklist. It should be wide spreaded in order to avoid anyone passing by the same problem which is really time consuming and desperating:
Have you enabled In-App Purchases for your App ID?
Have you checked Cleared for Sale for your product?
Have you submitted (and optionally rejected) your application binary?
Does your project’s .plist Bundle ID match your App ID?
Have you generated and installed a new provisioning profile for the new App ID?
Have you configured your project to code sign using this new provisioning profile?
Are you building for iPhone OS 3.0 or above?
Are you using the full product ID when when making an SKProductRequest?
Have you waited several hours since adding your product to iTunes Connect?
Are your bank details active on iTunes Connect? (via Mark)
Have you tried deleting the app from your device and reinstalling? (via Hector, S3B, Alex O, Joe, and Alberto)
Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work. (via oh my god, Roman, and xfze)
Are you logged out from real iTunes account?
Have you tried restarting device?
Are you on Device? (Will not work on Simulator)
Credits go to Troy Brant
Have a look here, that answered all of my questions (and the framework is simple to use, too :-):
http://blog.mugunthkumar.com/coding/iphone-tutorial-%E2%80%93-in-app-purchases/
But I have to say the whole in-app purchase thing is a PITA - my app just got released, and of course I downloaded it and checked the in-app purchase screen. Guess what, it came up completely empty!
After some reading up it seems that even if all is accepted and ready for sale, the in-app purchase products still need a while to become available online - after 3 hours it finally worked ...
EDIT:
You need to create the in-app purchase for your app and set it to clear for sale in itunes connect. You do not need to upload a screenshot yet or have it already reviewed in order to be able to test it in development mode.
How did you name the purchase in itunes connect? Normally you should use a com.companyname.productname.purchasename name, and the name you request from your app ha to be exactly the same.

IApp purchase doubts in iphone

Ha ii,everybody.I have a reader application which has a database downloading option through inapp,that is,the user can download the diffrent languages of databse(Sqlite) through inapp.I i added the classes from MugunthKumar classes and added it into the project.I have 5 buttons hindiDB,HebrewDB,japaneseDB,portuguesDB etc,etc.If the user tap any of the button above it will automatically connect to in-app and if the payment done ,it need to download that DB to my app.I write this code in one of my button click:
-(IBAction)_clickbtnhindilang:(id)sender
{
[[MKStoreManager sharedManager] buyFeature:kFeatureAId
onComplete:^(NSString* purchasedFeature)
{
NSLog(#"Purchased: %#", purchasedFeature);
}
onCancelled:^
{
NSLog(#"User Cancelled Transaction");
}];
}
and the console shows that it cannot built in ios stumulator and ned to build in realdevise,so i build it with a real devise and the console shows
Review request cannot be checked now: (null)
2011-12-06 14:39:33.958 Bible[965:707] User cancelled transaction: <SKPaymentTransaction: 0x373110>
2011-12-06 14:39:33.961 Bible[965:707] error: Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo=0x3dc4d0 {NSLocalizedDescription=Cannot connect to iTunes Store}
I didnt know how to do a inapp purchase.How can done this with MukunthKumar storekit class.
Thanks in advance.
Look here
http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/
And slow down a little bit, your rush will prevent you from learning.
Shani

iPhone: Cannot test InAppPurchase in sandbox after it is approved

I have a free iPhone App which uses in app purchase. I tested my first InAppPurchase with sandbox environment and it worked fine. After the InAppPurchase was approved and worked fine in App store, I added several new InAppPurchases in iTunes Connect and tried to test them in the sandbox environment. However I could not find these new InAppPurchases in my app.
The following is the code I uses to get InAppPurchase products:
//....
SKProductsRequest *prodRequest= [[SKProductsRequest alloc] initWithProductIdentifiers:
[NSSet setWithObject: prod]];
prodRequest.delegate = self;
[prodRequest start];
//....
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
int count = [response.products count];
NSLog(#"number of products:%d",count);
for (int i=0; i < count; i++) {
SKProduct* product = [response.products objectAtIndex:i];
NSLog(#"product %d:id=%# title=%# desc=%# price=%#", i, product.productIdentifier, product.localizedTitle,
product.localizedDescription,
product.price);
}
}
If I use the old InAppPurchase product id I can get it, but if I use any newly created product id I got count==0.
From what I saw, I guess may app may not be running in the sandbox environment after my first InAppPurchase was approved, but this is just a guess, because I don't know how to check if my app is in sandbox mode or not.
I searched Internet about this issue and tried the following:
1. created a new version of my app, uploaded it to iTunes connect, and rejected the binary. no use
2. deleted all my provisioning profiles and created new ones. no use
3. created an app id for my app in developer provisioning portal and created provisioning profile for that id and used it in Xcode. no use
My Xcode version was 3.2.5. I upgraded it to 4 but this did not fix the problem.
I am wondering if any one else has seen this issue and found a solution. Thanks.
OK I came across this post and got some hint:
Product Identifiers Are Valid On One Phone But Not Another
I just deleted the app from my iPod Touch, did not reboot, then tried to run my app from Xcode again, and it worked. I guess there was some states saved together with the app which determines whether to use sandbox environment for InAppPurchase or not. Although I could run my newly compiled binary without deleting the old app, I could not get rid of some old state which caused the app not running in the sandbox environment. That is what caused the problem. The solution is to delete the old app from the device before running newly compiled binary.

In App Purchase - can get product info but can't connect to itunes for purchase

I'm trying to make "In App Purchase " works in my iphone app.
I created some products and a few test accounts in itunes connect.
I have no problem to retreive the products data (prices etc..) but when I try to make a payment
- I am asked to log in
- I use a test account
-> the transaction always fail with the following error :
failedTransaction with error : Error Domain=SKErrorDomain Code=2 "Connexion à l’iTunes Store impossible" UserInfo=0x65d02a0 {NSLocalizedDescription=Connexion à l’iTunes Store impossible}
I tried with several products and test account (even in other stores like us) but I still get the same error...
NB : I think it worked fine the first time I tried but never still
Any idea will be welcome !
Thanks
For me, I just scoured my code until I found my mistake. I was so certain everything was fine, but it was not. When I requested product information from the store, I used the correct Product Identifier:
self.productRequest= [[[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: #"com.popculturesoft.RC_vCar.fullVersion"]] autorelease];
However, when I went to create the payment, I used the incorrect Product Identifier:
SKPayment *payment = [SKPayment paymentWithProductIdentifier:#"com.popculturesoft.RC_vCar_Lite.fullVerson"];
Using the product Identifier for the payment is not the correct way to do it, although it allows you to do it. It is better to use an SKProduct object. (I had set the fullProduct property earlier in the code:
SKPayment *payment = [SKPayment paymentWithProduct:self.fullProduct];
I was absolutely certain that the store was down, and that was the problem. But the next day I decided to start from the beginning of the process, as described in http://developer.apple.com/library/ios/#technotes/tn2259/_index.html. This is when I found that my incorrect Product Identifier was the problem.
Check out this thread. It seems to be a problem with the Sandbox. Lot's of people having this issue-
iPhone storekit sandbox stopped working
I had the same symptoms and in my case the problem was that I had a test user account with the same name as a real Apple ID account. I resolved the problem by creating a different test user account.