1.在开始IAP开发前,先要对IAP有个大概的了解,下面这片文章就是给你预备的:
苹果的官方文档:Store Kit Guide(In App Purchase)
现在网上已经有对这个文档很成熟的翻译了,如果想加快阅读速度,看这里
翻译版本:http://yarin.blog.51cto.com/1130898/549141
PS:开始IAP开发并不需要多深的背景知识,这里囫囵看下去就可以了。但是要了解IAP的两种验证形式: 设备验证和服务器验证。
2.网上流传比较广的IAP开发流程的帖子,讲的范围很全面,但是有的内容跟不上时代了,一共有两点需要注意:
一、在现在的IAP测试中,已经不需要提交程序再让开发者把程序状态设置“Developer Reject”了,只需要程序 到”prepare for upload“就可以了。
二、在IOS5,已经可以在模拟器中测试,调试IAP这个功能了。
这一篇文章地址是:
IAP(程序内购买): 完全攻略
http://fei263.blog.163.com/blog/static/927937242011321105241823/
这篇文章包含了从创建APP ID 开始到IAP基本功能实现的整个流程,很全面,值得花时间去看一看,但是注意几个问题:
1.文中有几个前置条件没有说明:
<1 在添加Test User之前,应该已经设置好ITunes Connect账户中关于Purchase Contract的信息。至少应该点击contract 的request按钮,让contract置于pending in process的状态。
完成上面的操作后,你才会在刚进入Manage User界面的时候,能选择创建Test User。
3.请保证这个时候你的pruchase contract已经完成了!contract中的 bank info,tax info,contact info都需要填写完成!
这篇帖子是这里要推荐的,主要介绍了Itunes Connect中创建了程序信息后,IAP的准备和测试的过程:
【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!
http://blog.csdn.net/xiaominghimi/article/details/6937097
4.遇到问题了?
好了,经过前面的准备后,就到了真正和IAP联通的步骤了。在输入一个Product ID向服务器发起request的时候,很有可能出现失败的情况,在request属性InvalidateIdentifier中,你会发现这个Product ID是无效的。
为什么呢?苹果是不会告诉你的,连个错误代码都没有,非常坑爹。
所以这里我们有一个Check List,需要大家逐条检查:
Have you enabled In-App Purchases for your App ID?
Have you checked Cleared for Sale for your product?
Have you submitted (and optionally rejected) your application binary?
Does your project’s .plist Bundle ID match your App ID?
Have you generated and installed a new provisioning profile for the new App ID?
Have you configured your project to code sign using this new provisioning profile?
Are you building for iPhone OS 3.0 or above?
Are you using the full product ID when when making an SKProductRequest?
Have you waited several hours since adding your product to iTunes Connect?
Are your bank details active on iTunes Connect? (via Mark)
Have you tried deleting the app from your device and reinstalling? (via Hector, S3B, Alex O, Joe, and Alberto)
Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work. (via oh my god, Roman, and xfze)
If you answered “No” to any one of these questions, there’s your problem.
If you answered “Yes” for each of these questions and you still have an invalid product ID, then you have a problem I haven’t seen before. Check out the links in the next section, several of which are Developer Forum posts that were especially helpful in my hunt for debugging invalid product IDs.
5.再使用别人提供的例子代码测试IAP完成以后,这里向你介绍一个别人封装好的类库:ECPurchase
http://www.cocoachina.com/bbs/read.php?tid-38555.html
类库在附件中下载。
wjforstudy分享了IAP的一些基本知识。在论坛的地址是:http://www.cocoachina.com/bbs/read.php?tid=92060