问题1:读取的内购商品列表不是添加时的顺序
解决步骤:由于我是使用的 react-native-iap 组件开发的,所以使用的是 JavaScript 数组排序,代码如下:
const products = await RNIap.getProducts(itemSkus);
const orderedProducts = products.sort((left, right) => left.price - right.price);
这样就是按价格从低到高排序了。
问题2:无法连接到 iTunes Store
解决步骤: 进入 WiFi,找到「配置 DNS」,设置为「手动」,在最顶部添加「114.114.114.114」或「8.8.8.8」,记得点右上角「存储」。注意:该错误可能与「问题4」互斥
问题3:App 内购时,提示说:此时没有权限在Sandbox购买此InApp
解决步骤:
- 打开 https://appstoreconnect.apple.com/access/testers
- 添加 Sandbox 测试账号,注册时一定要填写
真实邮箱
,点击邀请,然后登录刚刚的邮箱,验证地址 - 就可以免费测试自己 APP 的内购项了。
问题4:App 内购时,如果报「E_UNKNOWN」、「underlying error」、「https://sandbox.itunes.apple.com」、「无法连接到 iTunes Store」
{
"framesToPop": 1,
"code": "E_UNKNOWN",
"nativeStackIOS": [
"0 myapp 0x0000000104c547d4 RCTJSErrorFromCodeMessageAndNSError + 92",
"1 myapp 0x0000000104c2fb74 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.194 + 108",
"2 myapp 0x000000010453c674 -[RNIapIos rejectPromisesForKey:code:message:error:] + 320",
"3 myapp 0x000000010453dde4 __37-[RNIapIos request:didFailWithError:]_block_invoke + 136",
"4 libdispatch.dylib 0x0000000106fcd220 _dispatch_client_callout + 16",
"5 libdispatch.dylib 0x0000000106fdaa40 _dispatch_queue_barrier_sync_invoke_and_complete + 120",
"6 myapp 0x000000010453dd2c -[RNIapIos request:didFailWithError:] + 188",
"7 StoreKit 0x0000000198c43fa8 <redacted> + 232",
"8 libdispatch.dylib 0x0000000106fcd260 _dispatch_call_block_and_release + 24",
"9 libdispatch.dylib 0x0000000106fcd220 _dispatch_client_callout + 16",
"10 libdispatch.dylib 0x0000000106fd1db0 _dispatch_main_queue_callback_4CF + 1180",
"11 CoreFoundation 0x0000000184cef070 <redacted> + 12",
"12 CoreFoundation 0x0000000184cecbc8 <redacted> + 2272",
"13 CoreFoundation 0x0000000184c0cda8 CFRunLoopRunSpecific + 552",
"14 GraphicsServices 0x0000000186bef020 GSEventRunModal + 100",
"15 UIKit 0x000000018ebed78c UIApplicationMain + 236",
"16 myapp 0x0000000104511c40 main + 136",
"17 libdyld.dylib 0x000000018469dfc0 <redacted> + 4"
],
"userInfo": {
"NSErrorFailingURLKey": null,
"_kCFStreamErrorDomainKey": 4,
"NSErrorFailingURLStringKey": "https://sandbox.itunes.apple.com/WebObjects/MZStore.woa/wa/fetchSoftwareAddOns?appAdamId=0&icuLocale=zh_CN&bvrs=190315&sfId=143465-19,29&bid=com.myapp.bundleName&appExtVrsId=0",
"_kCFStreamErrorCodeKey": -2102,
"NSLocalizedDescription": "无法连接到 iTunes Store",
"NSUnderlyingError": {
"code": "-1001",
"nativeStackIOS": [
"0 myapp 0x0000000104c547d4 RCTJSErrorFromCodeMessageAndNSError + 92",
"1 myapp 0x0000000104c549c0 RCTJSErrorFromCodeMessageAndNSError + 584",
"2 myapp 0x0000000104c2fb74 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.194 + 108",
"3 myapp 0x000000010453c674 -[RNIapIos rejectPromisesForKey:code:message:error:] + 320",
"4 myapp 0x000000010453dde4 __37-[RNIapIos request:didFailWithError:]_block_invoke + 136",
"5 libdispatch.dylib 0x0000000106fcd220 _dispatch_client_callout + 16",
"6 libdispatch.dylib 0x0000000106fdaa40 _dispatch_queue_barrier_sync_invoke_and_complete + 120",
"7 myapp 0x000000010453dd2c -[RNIapIos request:didFailWithError:] + 188",
"8 StoreKit 0x0000000198c43fa8 <redacted> + 232",
"9 libdispatch.dylib 0x0000000106fcd260 _dispatch_call_block_and_release + 24",
"10 libdispatch.dylib 0x0000000106fcd220 _dispatch_client_callout + 16",
"11 libdispatch.dylib 0x0000000106fd1db0 _dispatch_main_queue_callback_4CF + 1180",
"12 CoreFoundation 0x0000000184cef070 <redacted> + 12",
"13 CoreFoundation 0x0000000184cecbc8 <redacted> + 2272",
"14 CoreFoundation 0x0000000184c0cda8 CFRunLoopRunSpecific + 552",
"15 GraphicsServices 0x0000000186bef020 GSEventRunModal + 100",
"16 UIKit 0x000000018ebed78c UIApplicationMain + 236",
"17 myapp 0x0000000104511c40 main + 136",
"18 libdyld.dylib 0x000000018469dfc0 <redacted> + 4"
],
"userInfo": {
"_kCFStreamErrorDomainKey": 4,
"_kCFStreamErrorCodeKey": -2102
},
"message": "underlying error",
"domain": "kCFErrorDomainCFNetwork"
}
},
"domain": "NSURLErrorDomain",
"line": 16,
"column": 1610,
"sourceURL": "/var/containers/Bundle/Application/76B091DA-009F-4825-8232-0D594EC6D101/myapp.app/main.jsbundle"
}
解决步骤:
解决步骤: 进入 WiFi,找到「配置 DNS」,设置为「自动」,点右上角「存储」。注意:该错误可能与「问题2」互斥