chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

Getting SKErrorDomain when trying to purchase #146

Closed bitfabrikken closed 6 years ago

bitfabrikken commented 6 years ago

Any ideas? Running on iOS 11 device, trying to make a purchase. I am signed into itunes account on the iPhone, and there is an internet connection.

InAppUtils.purchaseProduct("productname", (error, response) => {
       console.log("purchaseProuct callback");
        // NOTE for v3.0: User can cancel the payment which will be available as error object here.
        if (error) {
          console.log(error); //look below for the output
        }

        if(response && response.productIdentifier) {
           Alert.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
           //unlock store here.
        }
     });

output of error:

{ code: 'ESKERRORDOMAIN0',
  nativeStackIOS: 
   [ '0   sangbog                             0x0000000102cca790 RCTJSErrorFromCodeMessageAndNSError + 152',
     '1   sangbog                             0x0000000102cca6b8 RCTJSErrorFromNSError + 264',
     '2   sangbog                             0x0000000102f222b8 -[InAppUtils paymentQueue:updatedTransactions:] + 604',
     '3   StoreKit                            0x00000001988d0278 <redacted> + 104',
     '4   CoreFoundation                      0x0000000185491c20 CFArrayApplyFunction + 80',
     '5   StoreKit                            0x00000001988d01f4 <redacted> + 148',
     '6   StoreKit                            0x00000001988d122c <redacted> + 1220',
     '7   StoreKit                            0x00000001988d1dfc <redacted> + 144',
     '8   StoreKit                            0x00000001988d00a0 <redacted> + 168',
     '9   libdispatch.dylib                   0x000000010375149c _dispatch_call_block_and_release + 24',
     '10  libdispatch.dylib                   0x000000010375145c _dispatch_client_callout + 16',
     '11  libdispatch.dylib                   0x0000000103756050 _dispatch_main_queue_callback_4CF + 1192',
     '12  CoreFoundation                      0x0000000185573f20 <redacted> + 12',
     '13  CoreFoundation                      0x0000000185571afc <redacted> + 2012',
     '14  CoreFoundation                      0x00000001854922d8 CFRunLoopRunSpecific + 436',
     '15  GraphicsServices                    0x0000000187323f84 GSEventRunModal + 100',
     '16  UIKit                               0x000000018ea3e880 UIApplicationMain + 208',
     '17  sangbog                             0x0000000102b707c8 main + 124',
     '18  libdyld.dylib                       0x0000000184fb656c <redacted> + 4' ],
  userInfo: { NSLocalizedDescription: 'Kan ikke oprette forbindelse til iTunes Store' },
  message: 'Kan ikke oprette forbindelse til iTunes Store',
  domain: 'SKErrorDomain' }
bitfabrikken commented 6 years ago

Well that was my bad :) Had forgotten to enable In App Purchases under Capabilities in the Xcode project. The error can occur due to many things, but in this case it was no IAP capability :)