Skip to content

Instantly share code, notes, and snippets.

@NorrinRadd
Created July 10, 2014 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NorrinRadd/e6cab8715c18048d506e to your computer and use it in GitHub Desktop.
Save NorrinRadd/e6cab8715c18048d506e to your computer and use it in GitHub Desktop.
/* Native binding */
extern "C" {
void _requestProducts(
char** sProductIdentifiers, uint32_t rp_len,
ManagedRequestCallback callback) {
NSMutableSet* productIdentifiers = [[NSMutableSet alloc] initWithCapacity:20];
for (int i=0; i<rp_len; i++) {
[productIdentifiers addObject:GetStringParam(sProductIdentifiers[i])];
}
SKProductsRequest* productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
DMCTIAPStoreKitDelegate* delegate = [DMCTIAPStoreKitDelegate sharedInstance];
delegate.callback = callback;
productsRequest.delegate = delegate;
[productsRequest start];
}
}
/* DMCTIAPStoreKitDelegate */
typedef void (*ManagedRequestCallback)
( bool success, sk_product products[],
uint32_t nProducts, char* invalidProducts[],
uint32_t nInvalidProducts );
@interface DMCTIAPStoreKitDelegate : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>
@property (nonatomic) ManagedRequestCallback callback;
@end
@implementation
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
. . . .
_callback(true, _products, retProductsLength, _invalidProducts, retInvalidProductsLength);
. . . .
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment