Seeing intermittent crashes on canMakePaymentsUsingNetworks() IPhone 6 and 6+

Hey there,


Upon creating a new build and .ipa of our application apple pay looks to be crashing sometimes on the IPhone 6 and 6+ models. It looks to be blowing up when it tried to invoke canMakePaymentsUsingNetworks on the PKPaymentAuthorizationViewController. Our code implementaiton of this has not changes and it works fine on the 7 and X, but only after a few tries on the 6 and 6+. Our analytics tool is throwing SIGSEV crashes that look something like this

Thread 3 Crashed:
0   libobjc.A.dylib                     0x000000018281d7f4 objc_object::release() + 16
1   PassKitCore                         0x0000000195e5bfc4 +[PKPaymentAuthorizationCoordinator canMakePaymentsUsingNetworks:webDomain:] + 76
2   SalesAndServiceApplication          0x0000000100b3b528 __45-[ApplePayImpl canMakePaymentsUsingNetworks:]_block_invoke (ApplePayImpl.m:44)
3   libdispatch.dylib                   0x0000000182f36a54 _dispatch_call_block_and_release + 24
4   libdispatch.dylib                   0x0000000182f36a14 _dispatch_client_callout + 16
5   libdispatch.dylib                   0x0000000182f3dbc8 _dispatch_queue_override_invoke$VARIANT$mp + 716
6   libdispatch.dylib                   0x0000000182f43cf4 _dispatch_root_queue_drain + 600
7   libdispatch.dylib                   0x0000000182f43a38 _dispatch_worker_thread3 + 120
8   libsystem_pthread.dylib             0x00000001831df06c _pthread_wqthread + 1268
9   libsystem_pthread.dylib             0x00000001831deb6c start_wqthread + 4


Our Implemetation of the code is as follows


/*
* Checks the PassKit method for determining if the device has any cards in PassBook that will work with
* this application
*
*/
- (void) canMakePaymentsUsingNetworks:(CDVInvokedUrlCommand *)command{
    [self.commandDelegate runInBackground:^{
        CDVCommandStatus status = CDVCommandStatus_ERROR;
      
        if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:[ApplePayConfig paymentNetworks]]) {
            status = CDVCommandStatus_OK;
        }
      
        [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:status] callbackId:command.callbackId];
    }];
}


we are also calling canMakePayments before this method in the following way


/*
* Checks the PassKit method for determining if Apple Pay is enabled or available on this device
* As of iOS 8, the Simulator does not support ApplePay.
*
*/
- (void) canMakePayments:(CDVInvokedUrlCommand *)command{
    [self.commandDelegate runInBackground:^{
        CDVCommandStatus status = CDVCommandStatus_ERROR;
       
        if ([PKPaymentAuthorizationViewController canMakePayments]) {
            status = CDVCommandStatus_OK;
        }
       
        [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:status] callbackId:command.callbackId];
    }];
}


One interesting thing is that we are able to reproduce the crashes the majority of the time with .ipa's downloaded from TestFlight or directly from the app store, but it's a lot harder with development builds or running a device tethered to xCode (we haven't been able to reproduce it this way). If anyone has any insights at all it would be greatly appreciated!

Replies

We encountered the same crash. But our crashes only happened on iOS 9.3.x and I can't reproduce the crash by device iPhone 6 iOS version is 9.3.1. Our code is as follows:


if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkChinaUnionPay]])
    { 
        return SQLocalizationString(SQPayWithApplePay);
    } else {
        return SQLocalizationString(SQSetupApplePay);
    }



The following code cause the crash:
 if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkChinaUnionPay]])


I don't know why this code could cause a crash. If anybody knows why please give me some clue. Thanks a lot!