mattt / CargoBay

The Essential StoreKit Companion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CargoBay

Note: This project is no longer being maintained.

StoreKit is the Apple framework for making In-App Purchases. It's pretty good, but it has a few rough edges.

CargoBay smooths out those rough parts by providing:

  • One step receipt & transaction verification, done securely according to Apple's guidelines
  • Block-based interface for requesting product information
  • Ability to request product information for identifiers asynchronously from a remote web service
  • Block-based callbacks for payment queue observation delegate methods
  • Automatic check for transaction uniqueness

Usage

Product Requests

NSArray *identifiers = @[
  @"com.example.myapp.apple",
  @"com.example.myapp.pear",
  @"com.example.myapp.banana"
];

[[CargoBay sharedManager] productsWithIdentifiers:[NSSet setWithArray:identifiers]
success:^(NSArray *products, NSArray *invalidIdentifiers) {
  NSLog(@"Products: %@", products);
  NSLog(@"Invalid Identifiers: %@", invalidIdentifiers);
} failure:^(NSError *error) {
  NSLog(@"Error: %@", error);
}];

Payment Queue Observation

AppDelegate.m

- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {
  [[CargoBay sharedManager] setPaymentQueueUpdatedTransactionsBlock:^(SKPaymentQueue *queue, NSArray *transactions) {
    NSLog(@"Updated Transactions: %@", transactions);
  }];

  [[SKPaymentQueue defaultQueue] addTransactionObserver:[CargoBay sharedManager]];

  // ...
}

Verifying Receipts

[[CargoBay sharedManager] verifyTransaction:transaction password:nil success:^(NSDictionary *receipt) {
  NSLog(@"Receipt: %@", receipt);
} failure:^(NSError *error) {
    NSLog(@"Error %d (%@)", [error code], [error localizedDescription]);
}];

License

CargoBay is available under the MIT license. See the LICENSE file for more info.

About

The Essential StoreKit Companion

License:MIT License


Languages

Language:Objective-C 99.5%Language:Ruby 0.4%Language:Makefile 0.1%