mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Fix IAP for iOS: apply()'s "this" argument needs to be set.
When I changed the JS callbacks to use `apply()`, I left the "this" argument set to null. This caused code in InAppPurchaseManager.prototype.updatedTransactionCallback to fail because references to `this` become null instead of references to the default instance of InAppPurchaseManager. This commit modifies the apply() calls to use plugins.inAppPurchaseManager as the "this" argument.
This commit is contained in:
@@ -153,7 +153,7 @@
|
||||
NILABLE(productId),
|
||||
NILABLE(transactionReceipt),
|
||||
nil];
|
||||
NSString *js = [NSString stringWithFormat:@"plugins.inAppPurchaseManager.updatedTransactionCallback.apply(null, %@)", [callbackArgs JSONSerialize]];
|
||||
NSString *js = [NSString stringWithFormat:@"plugins.inAppPurchaseManager.updatedTransactionCallback.apply(plugins.inAppPurchaseManager, %@)", [callbackArgs JSONSerialize]];
|
||||
NSLog(@"js: %@", js);
|
||||
[self writeJavascript: js];
|
||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||
@@ -191,7 +191,7 @@
|
||||
NILABLE(product.localizedDescription),
|
||||
NILABLE(product.localizedPrice),
|
||||
nil];
|
||||
NSString *js = [NSString stringWithFormat:@"%@.apply(null, %@)", successCallback, [callbackArgs JSONSerialize]];
|
||||
NSString *js = [NSString stringWithFormat:@"%@.apply(plugins.inAppPurchaseManager, %@)", successCallback, [callbackArgs JSONSerialize]];
|
||||
NSLog(@"js: %@", js);
|
||||
[command writeJavascript: js];
|
||||
}
|
||||
@@ -245,7 +245,7 @@
|
||||
NILABLE(validProducts),
|
||||
NILABLE(response.invalidProductIdentifiers),
|
||||
nil];
|
||||
NSString *js = [NSString stringWithFormat:@"%@.apply(null, %@);", callback, [callbackArgs JSONSerialize]];
|
||||
NSString *js = [NSString stringWithFormat:@"%@.apply(plugins.inAppPurchaseManager, %@);", callback, [callbackArgs JSONSerialize]];
|
||||
[command writeJavascript: js];
|
||||
|
||||
[request release];
|
||||
|
||||
Reference in New Issue
Block a user