iOS react-native-in-app-utils InAppUtils.purchaseProduct在不同订阅之间切换时返回错误

时间:2017-09-22 20:02:58

标签: javascript ios react-native in-app-purchase subscriptions

我在同一订阅级别下有四种不同的订阅:

trainee.monthly

trainee.annual

pro.monthly

pro.annual

每当我独立订阅每个产品时,购买都可以。问题是当我尝试管理订阅时。使用我上面描述的当前iTunes连接配置,我可以从trainee.monthly切换到pro.monthly,然后从trainee.annual切换到pro.annual并返回,但没有其他工作。我尝试以多种方式将订阅移动到iTunes连接中的不同级别,但是从未达到想要的行为(想要的行为能够在任何订阅之间切换)。

我得到的错误如下所示:

{"代码":" ESKERRORDOMAIN0","消息":"无法连接到iTunes Store"," nativeStackIOS&# 34;:[" 0 RouteTest 0x0000000100176d5c RCTJSErrorFromCodeMessageAndNSError + 152"," 1 RouteTest 0x0000000100176c84 RCTJSErrorFromNSError + 264"," 2 RouteTest 0x00000001002b8f5c - [InAppUtils paymentQueue:updatedTransactions:] + 604&# 34;," 3 StoreKit 0x0000000197e206e4 + 104"," 4 CoreFoundation 0x000000018ac2a710 CFArrayApplyFunction + 68"," 5 StoreKit 0x0000000197e20660 + 148"," 6 StoreKit 0x0000000197e21158 + 1220"," 7 StoreKit 0x0000000197e21c78 + 144"," 8 StoreKit 0x0000000197e20510 + 152"," 9 libdispatch.dylib 0x00000001008c9a50 _dispatch_call_block_and_release + 24",&# 34; 10 libdispatch.dylib 0x00000001008c9a10 _dispatch_client_callout + 16"," 11 libdispatch.dylib 0x00000001008ceb78 _dispatch_main_queue_callback_4CF + 1204"," 12 CoreFoundation 0x000000018acfd0c8 + 12",&#34 ; 13 CoreFoundation 0x000000018acface4 + 1572"," 14 CoreFoundation 0x000000018ac2ada4 CFRunLoopRunSpecific + 424"," 15 GraphicsServices 0x000000018c695074 GSEventRunModal + 100"," 16 UIKit 0x0000000190ee5c9c UIApplicationMain + 208&#34 ;," 17 RouteTest 0x000000010001b9ec main + 124"," 18 libdyld.dylib 0x0000000189c3959c + 4"]," domain":" SKErrorDomain", " USERINFO&#34 ;: {" NSLocalizedDescription":"无法连接到iTunes Store"}

这是我的代码片段:

const makePurchase  = (product) =>{
Logger.logInfo("called makepurchase: " + product)
const { InAppUtils } = NativeModules
var products = []
products.push(product)
if (Platform.OS === 'ios') {
    return new Promise(function (resolve, reject) {
    InAppUtils.loadProducts(products, (error, products) => {
        Logger.logInfo("products are:")
        Logger.logInfo(products)
        InAppUtils.purchaseProduct(product, (error, response) => {

            if (error) {

                Logger.logInfo('error in purchase')
                Logger.logInfo(error)
                Logger.logInfo(response)
                return reject(error)
            }
            if(response && response.productIdentifier) {
                Logger.logInfo('Purchase Successful', 'Your Transaction receipt is ' + response.transactionReceipt)
                InAppUtils.receiptData((error, receiptData)=> {
            if(error) {
                        Logger.logInfo(error)
                        return reject(error)
            } else {
            //send to validation server
                    Logger.logInfo("receipt data" + receiptData)
                    var ret =  {
                                        "receiptData":receiptData,
                                    ...products[0]
                                    }
                    Logger.logInfo("return is...")
                    Logger.logInfo(ret)
                    return resolve(ret)
            }
                });
            }
            Logger.logInfo(response)
        })
    })
  })
}}

有没有人看到我做错或知道如何处理我描述的错误?

0 个答案:

没有答案