Steps:
A. Setup App
B. Setup Product & App Purchase Type Model Define.
C. Product Purchase Transaction
D. SandBox Testing
Step A: Setup App.
1.
Certificate is an essential element to submit or test an application on iphone. It comes with code sign(Signatures) which would verified when an application is submitted on apple store or when tested on iphone.
One has to through 2 step procedure to create a certificate from developer portal. I simply copied those two from “iphone developer portal”
1.1 Generating Certificate Signing Request
1.2 Submitting a Certificate Signing Request for Approval
1.3 Downloading and Installing Certificate .
1.4 Generating App ID.
1.5 create a Provisioning file for our Xcode and final step for creating binary which would submit it to Appstore.
1.1 Generating a Certificate Signing Request:
1.1.1 Open the Utilities folder and launch Keychain Access from the Applications folder.
1.1.2 Set the value of Online Certificate Status Protocol (OCSP) and Certificate Revocation List (CRL) to “off” in the Preferences Menu.
1.1.3 Select Keychain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.
1.1.4 Fill in your email address in User Email Address Field. Confirm that this email address is same as provided at the time of registering as iPhone developer.
1.1.5 Fill in your name in the Common Name field. Confirm that this name is same as provided at the time of registering as iPhone developer.
1.1.6 It is not necessary to have an Certificate Authority (CA). The ‘Required’ message would be eliminated after finishing the following step.
1.1.7 Click the ‘save to disk’ radio button if prompted, choose ‘Let me specify key pair information’ and proceed.
1.1.8 If you choose ‘Let me specify key pair’ option then one has provide a file name and click ‘Save’. Select ‘2048 bits’ for Key Size and ‘RSA’ for the algorithm in next screen and proceed.
1.1.9 CSR file would created on the desktop by Certificate Authority.
1.2 Submitting a Certificate Signing Request for Approval:
1.2.1 Once CSR file is created log in to the iPhone developer program portal and go to ‘Certificates’> ‘Development’ and select ‘Add Certificate’.
1.2.2 Click the ‘Choose file’ button, select your CSR and click ‘Submit’. The portal will reject the CSR if Key Size is not set to 2048 bit at the time of CSR creation.
1.2.3 This will followed by notification to Team Admins by email of the certificate request.
1.2.4 The change in the certificate status would informed by email on approval or rejection of the CSR by Team Admin.
1.3 Download/Installing Certificate on your machine
1.3.1 Once the CSR is approved the Team Members and Team Admins can download their certificates via the ‘Certification’ section of the Program Portal. Choose ‘Download’ next to the certificate name to download your iPhone development certificate to your local machine.
1.3.2 Once this is done double-click the .cer file to launch Keychain Access and install your certificate.
On installation of certificate on your MAC the next step is to create an App ID.
1.4 Generate an App ID:
1.4.1 Go to ‘App IDs’ and click ‘App ID’ after logging in to iPhone developer program portal.
1.4.2 Populate the ‘App Id Name’ field with your application name (that is – FirstApp) and in ‘App Id’ enter something like com.yourdomain.applicationname (i.e com.dynamicmethods.firstapp) and click submit.
1.4.3 Please do note down the “App Id” as this would be utilized in Info.plist, bundle identifier tag.
1.5 create a Provisioning file for our Xcode and final step for creating binary which would submit it to Appstore.
1.5.1 After you navigate to ‘Provisioning’> ‘Distribution’ click ‘Add Profile’ in iphone developer program portal.
1.5.2 Choose “App Store” in “Distribution Method”.
1.5.3 In “Profile Name” enter your application name (i.e firstapp) which will be your provisioning profile name as well.
1.5.4 In “App ID” select the app name(i.e. firstapp) which you created in Step 1.4.
1.5.5 After downloading the Provisioning profile copy it to your/YourUserName/Library/MobileDevice/Provisioning Profile.
B. Setup Product & App Purchase Type Model Define.
Now We are ready setup Product which you want to sell thru App.
1.1 Setup Product
1.1.1 Login http://developer.apple.com and go to itune connect and select Manage in App Purchase Link.
1.1.2 Click Create New and Select your app (i.e firstapp)
1.1.3 Fill up product details such as
- Reference Name: common name for the product. I used “Product-A”. This name is non-editable, and it will not be displayed in the App Store.
- Product ID: unique id for your app. Typically of the form com.yourdomain.appname.productsku, but it can be whatever you want. It does not need to have your app’s App ID as a prefix.
- Type: You have 3 choices:
- Non-consumable: only pay once (use this if you want a free-to-pro-upgrade product
- Consumable: pay for every download
- Subscription: recurring payment
- Price Tier: price of the product. See the price matrix for the different tiers.
- Type: You have 3 choices:
-
- Cleared for Sale: check this now. If you don’t, you will get back an invalid product ID during testing.
- Language to Add: Pick one. The following two fields will appear:
- Displayed Name: Name of your product shown to your user. I chose “Buy Product A”.
- Description: What the product does. The text you enter here is sent along with the Displayed Name and Price when you fetch an
SKProductin code.
- Screenshot: Your feature in action. Despite the text on the screen about the screenshot submission triggering the product review process , you can safely add the screenshot now without the product being submitted for review. After saving the product, just choose the “Submit with app binary” option. This will tie the product to the app binary, so when you finally submit the 100% complete app binary, the product will be submitted as well.
- Click “Save”
1.6 Integration Code Add into your app.
To access the product data, we need to use the StoreKit framework. Testing only possible on device. not on simulator
- Add the
StoreKitframework to your project. - Add a reference to a
SKProductto your .h file:
// AppPurchaseManager.h
#import <StoreKit/StoreKit.h>
#define ProductsFetchedNotification @”ProductsFetchedNotification”
@interface AppPurchaseManager : NSObject <SKProductsRequestDelegate>
{
SKProduct *buyProductA;
SKProductsRequest *productsRequest;
}
AppPurchaseManager is a singleton class that handles every in app purchase for our app. It make easy integration within entire app.
Request the product, and implement the delegate protocol in the corresponding .m file:
// AppPurchaseManager.m
- (void)requestbuyProductAData
{
NSSet *productIdentifiers = [NSSet setWithObject:@"com.dynamicmethods.firstapp.productA" ];
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];// we will release the request object in the delegate callback
}#pragma mark -
#pragma mark SKProductsRequestDelegate methods- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *products = response.products;
buyProductA = [products count] == 1 ? [[products firstObject] retain] : nil;
if (buyProductA)
{
NSLog(@”Product title: %@” , buyProductA.localizedTitle);
NSLog(@”Product description: %@” , buyProductA.localizedDescription);
NSLog(@”Product price: %@” , buyProductA.price);
NSLog(@”Product id: %@” , buyProductA.productIdentifier);
}for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(@”Invalid product id: %@” , invalidProductId);
}// finally release the reqest we alloc/init’ed in requestbuyProductAData
[productsRequest release];[[NSNotificationCenter defaultCenter] postNotificationName:ProductsFetchedNotification object:self userInfo:nil];
}























































































