---
title: "苹果IAP注意事项"
author: "贝壳水母"
date: "2015-10-21T11:41:55Z"
tags: []
categories: ["移动开发"]
slug: "iap"
draft: false
lastmod: "2015-10-21T11:42:44Z"
id: 2250688
url: "https://shineonly.iteye.com/blog/2250688"
---

```crash log
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000018
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libc++abi.dylib               	0x337a1a64 __dynamic_cast + 212
1   xxxxxxxxx                    	0x00016482 0x4000 + 74882
2   xxxxxxxxx                    	0x00016868 0x4000 + 75880
3   xxxxxxxxx                    	0x00020d46 0x4000 + 118086
4   xxxxxxxxx                    	0x000208dc 0x4000 + 116956
5   StoreKit                      	0x26c23f8e __34-[skproductsrequest _handlereply:]_block_invoke + 506
```

被reject的iap product，localizedTitle和localizedDescription会是nil，如果直接  UTF8String]这样使用就会crash，产生类似上面这样的crash log
參考：<http://stackoverflow.com/questions/23657046/itunnes-skproduct-localizedtitle-is-nil>

＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝

测试流程：
·先退出设备上的appleID
·进游戏选iap充值
·弹出登录框输入iTunes后天配置的sandbox account
·完成测试后退出sandbox appleID（因为苹果规定sandbox账号不能在proudction环境使用）
参考：<https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/ShowUI.html#//apple_ref/doc/uid/TP40008267-CH3-SW11>

越狱设备可能无法测试iap，会报can not connect to iTunes store
如果明明账号密码正确却提示“The Apple ID you entered couldn't be found or your password was incorrect. Please try again”
需要重新配一个sandbox account
参考：<http://stackoverflow.com/questions/27049612/how-to-create-test-user-for-in-app-purchase-in-new-ituneconnect >