Created
July 10, 2014 22:58
-
-
Save NorrinRadd/e6cab8715c18048d506e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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