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:
David H
2011-12-08 14:42:23 -08:00
parent 36c5c4ae83
commit c7f577e076

View File

@@ -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];