[
https://issues.apache.org/jira/browse/CB-12310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15793281#comment-15793281
]
Bednarik Boldizsar commented on CB-12310:
-----------------------------------------
Details about the same bug for https://github.com/j3k0/cordova-plugin-purchase
cordova plugin:
`Thread 1: EXC_BAD_ACCESS (code=1, address=0x79869170)`
the brakepoing is in the file `inAppPurchase.m` line 364
> `[[SKPaymentQueue defaultQueue] addPayment:payment];`
here is the whole function:
```
- (void) purchase: (CDVInvokedUrlCommand*)command
{
DLog(@"About to do IAP");
id identifier = [command.arguments objectAtIndex:0];
id quantity = [command.arguments objectAtIndex:1];
SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:[self.list
objectForKey:identifier]];
if ([quantity respondsToSelector:@selector(integerValue)]) {
payment.quantity = [quantity integerValue];
}
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
```
this is what i have in xcode console window:
```
2016-12-13 17:48:28.526112 app[415:34889] THREAD WARNING: ['InAppPurchase']
took '13.864990' ms. Plugin should use a background thread.
2016-12-13 17:48:28.586510 app[415:34889] InAppPurchase[objc]: Getting products
data
2016-12-13 17:48:28.586721 app[415:34889] InAppPurchase[objc]: Set has 1
elements
2016-12-13 17:48:28.586779 app[415:34889] InAppPurchase[objc]: - xxxx
2016-12-13 17:48:28.586941 app[415:34889] InAppPurchase[objc]: Starting product
request...
2016-12-13 17:48:28.587193 app[415:34889] InAppPurchase[objc]: Product request
started
2016-12-13 17:48:29.495091 app[415:34889] InAppPurchase[objc]: productsRequest:
didReceiveResponse:
2016-12-13 17:48:29.495206 app[415:34889] InAppPurchase[objc]: Has 1
validProducts
2016-12-13 17:48:29.497921 app[415:34889] InAppPurchase[objc]: - xxxx: This is
a test subscription
2016-12-13 17:48:29.501294 app[415:34889] InAppPurchase[objc]: productsRequest:
didReceiveResponse: sendPluginResult: (
(
{
currency = USD;
description = "Just a test subscription description for sandbox";
id = "xxxx";
price = "$4.99";
title = "This is a test subscription";
}
),
(
)
)
2016-12-13 17:48:30.965666 app[415:34889] InAppPurchase[objc]: About to do IAP
```
> Getting EXC_BAD_ACCESS in xcode when trying to use any purchase plugin on IOS
> -----------------------------------------------------------------------------
>
> Key: CB-12310
> URL: https://issues.apache.org/jira/browse/CB-12310
> Project: Apache Cordova
> Issue Type: Bug
> Components: iOS
> Environment: env:
> Cordova CLI: 6.0.0
> OS: Mac OS X El Capitan
> Xcode version: Xcode 8.2.1 Build version 8C1002
> plugins
> cc.fovea.cordova.purchase 6.0.0 "Purchase"
> Reporter: Bednarik Boldizsar
> Labels: crash, ios, purchase
>
> I'm trying to use the
> https://github.com/AlexDisler/cordova-plugin-inapppurchase plugin in my
> ionic/cordova application, and I get an error in xcode when executing this
> code:
> ```
> var id = 'my_id';
> inAppPurchase
> .getProducts([id]).then(function (products) {
> // logging
> inAppPurchase.subscribe(id).
> then(function(data){
> // logging
> }).catch(function(err){
> // logging
> });
> }).catch(function (err) {
> // logging
> });
> ```
> I have tried with `ios 4.2.1` and `ios 4.3.1` as well, the problem comes up
> every time on 4.3.1 and sometimes but frequently on 4.2.1 ...
> here's what I get in xcode:
> ```
> Thread 1: EXC_BAD_ACCESS (code=1, address=0x600000028)
> ```
> this is in like 224 in `RMStore.m`
> `[[SKPaymentQueue defaultQueue] addPayment:payment];`
> here is the full function where the app dies:
> ```
> - (void)addPayment:(NSString*)productIdentifier
> user:(NSString*)userIdentifier
> success:(void (^)(SKPaymentTransaction *transaction))successBlock
> failure:(void (^)(SKPaymentTransaction *transaction, NSError
> *error))failureBlock
> {
> SKProduct *product = [self productForIdentifier:productIdentifier];
> if (product == nil)
> {
> RMStoreLog(@"unknown product id %@", productIdentifier)
> if (failureBlock != nil)
> {
> NSError *error = [NSError errorWithDomain:RMStoreErrorDomain
> code:RMStoreErrorCodeUnknownProductIdentifier
> userInfo:@{NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Unknown
> product identifier", @"RMStore", @"Error description")}];
> failureBlock(nil, error);
> }
> return;
> }
> SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
> if ([payment respondsToSelector:@selector(setApplicationUsername:)])
> {
> payment.applicationUsername = userIdentifier;
> }
>
> RMAddPaymentParameters *parameters = [[RMAddPaymentParameters alloc]
> init];
> parameters.successBlock = successBlock;
> parameters.failureBlock = failureBlock;
> _addPaymentParameters[productIdentifier] = parameters;
>
> [[SKPaymentQueue defaultQueue] addPayment:payment];
> }
> ```
> this is the related code form xcode console:
> ```
> 2016-12-13 17:03:32.366881 app[385:27165] RMStore: products request received
> response
> 2016-12-13 17:03:32.367172 app[385:27165] RMStore: received product with id
> my_id
> ```
>
> I'm using xcode 8.x ...
> I have been trying to solve this with no success so far. I tried to use
> different cordova versions, different cordova-ios versions and different
> versions of the plugin, the result is the same - the app crashes. The most
> frustrating thing is, sometimes it works, sometimes (most of the times) it
> does not ... and there's a pattern (sort of) when I run the app in XCode it
> usually works the first time, then if i kill the app, and start it from the
> phone it dies, then if I go to multitasking and click on the app again then
> it works ... the app dies right before (or maybe during) the purchase dialog
> appears. I have tried to create a totally new application, and reproduce the
> problem, could not do it - it showed the purchase dialog every time.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]