Simple And Safe In-App Purchase Using Parse

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

In iOS development, setting up in-app purchases (IAPs) can be a challenge. If the IAP requires downloading associated content, developers have to build a backend that can deliver these content files securely. The backend should only make the content available to the user after the purchase has been validated by the server. If your server skips this important validation step, the content will be susceptible to digital theft. This can be a lot of work.

At Parse, we have heard a lot about the difficulties of integrating IAPs from our developer community. Today, we are introducing Parse’s IAP solution, which addresses the problems and is simpler to use than Store Kit. Let’s say you want to sell a product named “Pro” that gets rid of all the ads in the app:

// First, register a handler for the product
[PFPurchase addObserverForProduct:@"Pro" block:^(SKPaymentTransaction *transaction) {
    // Write business logic that should run once this product is purchased.
    isPro = YES;

// ... Later, when the user is purchasing the product:
[PFPurchase buyProduct:@"Pro" block:^(NSError *error) { ... }];

Parse can host your digital downloads and deliver them securely. Using the data browser, you can upload the content files to the Product class on Parse. To download the file in the app:

[PFPurchase addObserverForProduct:@"Pro" block:^(SKPaymentTransaction *transaction) {
    [PFPurchase downloadAssetForTransaction:transaction completion:
            ^(NSString *filePath, NSError *error) { ... }];

// ... Later, when the user is purchasing the product:
[PFPurchase buyProduct:@"Pro" block:^(NSError *error) { ... }];

The call to +[PFPurchase downloadAssetForTransaction:completion:] will tell Parse to validate the transaction with Apple before making the download available. Parse makes it easy for you to work with in-app purchases in a way that safeguards your digital downloads.

More information can be found in our documentation. And as always, your feedback is welcome.

via Hacker News

Leave a comment

Filed under Auto

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s