vendredi 26 mars 2010

Testing Inapp purchases for an iPhone application ..

... is HELL. Final. But workable.

My main problem when trying to test inapp purchase was the dreadful and hard to debug 'Invalid product id' state of my SKProductsRequest object.

So i wrote a little helper (mainly for myself), to guide along the hard path to a successful inapp purchase.

First, i found VERY valuable informations on these links:
As a reminder the very first step of an inapp purchase is to 'register' the ids of the products (productId) you want to use in your app.

This is done with code like (see: http://yaus.eu/ykml)
...
NSSet *productIdentifiers = [NSSet setWithObject:@"my.complete.product.id" ];
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
...

You register your products (be careful with the name, it must be complete !), and send a request to the appstore.

Provided that:
  • you're not connected with any itunes account,
  • you're running the app with XCode (mandatory, connexion to the sandbox is only via XCode),
this first step will attempt to connect to the appstore and check the available products for you application id.

From what i've read (a lot!), about 90% of errors in inapp purchases can be detected at this very point.

On the callback method (productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
), if there's no products in the response (response.products)
-> THERE'S NO NEED TO GO FURTHER: YOU'RE OUT !

Refer to http://yaus.eu/fwmj to see all possible causes of an invalid product id.

In the present case, my errors were the following...

1 - I sent a binary of the app and then rejected it

DON'T EVER PUBLISH YOUR BINARY!

Inapp testing MUST be done without sending the binary of your app. If any reject occurs (app or developper), the whole process is crashed.


2 - My provisioning profile was not configured to use in app. Yeah. Dumb. But not so obvious.

CREATE A SPECIFIC CERTIFICATE ONLY FOR YOUR APP !

Don't forget to fully qualify the name of the app, no wildcards in it.


3 - I approved my app purchase.

DON'T !


4 - i connected with the test account OUTSIDE Xcode

NEVER CONNECT WITH THE ITUNES-CONNECT DEV/TEST ACCOUNT OUTSIDE OF XCODE !

The fact of running in XCode redirects automatically to the sandbox. On the opposite, when not running in XCode, if you use your test account, it will be considered as a production account.


One final point, when you create an app and you don't submit a binary, the bundle id of the app is not set.

No to worry about.

The creation of a valid provisionning profile in the portal is autodetected by itunes connect and when managing the new inapp purchase, you will be asked for a bundle id in a list of 'inapp enabled' certificates.

lundi 4 janvier 2010

MongoDB first impressions

I'm always looking for a good replacement for standard RDBMS when there is no (or little) need for it.
Maybe to satisfy to the K.I.S.S. agile axiom. 'Keep it stupid simple'.

I must say that 90% of the db oriented applications that i wrote or contributed to in the last 15 years (yeah, i'm an elder :) ) could have been done without a relational database but lacked good products to do so.

And the rate goes up to 99% when the application is document oriented (whatever the format).

Poor conception, bad practices, models with 50+ joins for querying, no concurrency concerns and so on, finished making up my mind: RDBMS can really be evil when put in unskilled hands.

So, in this era of 'Cloud Everywhere', venerable hashkey databases (NoSQL) are up for revenge.

One amongst them have retained my attention: mongodb (http://www.mongodb.org).

Simple, opensource, C++, fast, and java drivers available. Many good points.

I will try in further entries to see/test if mongodb can act, when possible, as a replacement for my beloved PostgreSQL/JPA layer in Java applications.

Stay tuned...

'jikarius.blogspot.com' creation

Welcome to my new dev blog and to the brand new 2010 year !

You will find here java, groovy, sql (and more) stuffs or IT interest of the moment.

Enjoy !