iOS 11 IAP推荐商品接入

  • 0x00 官方文档链接地址

    官方介绍   

  • 0x01 表现、玩法

    1. 首先你需要将你的手机系统升级到 iOS 11.xx以上

    2. 在应用的介绍界面中你可以看到一个特别的商品(如果应用配置了IAP推荐商品)

    3. 你可以在appstroe中点击购买该商品

    4. 如果你已经安装过这个应用,哪么appstore会打开该应用,如果你没有安装过这个应用,appstore会提示你购买该app并下载后打开该应用

    5. 进入应用成功后会提示购买信息,执行购买流程

  • 0x02如何配置你的应用支持IAP商品推荐

    1. 首先你需要在你的开发者账号下创建应用、创建商品。

    2. 在消耗性型商品是会有如下图的提示:

     

    你只需要上传一个图片资源就可以将你的商品定制为推荐商品,该图片要求为1024*1024 ,苹果会将你的图片右上角进行弧形切割显示。

  • 0x30 程序如何支持

    1. 你的程序需要监听iOS 11 StoreKit中的

    

    该函数为bool行返回

    根据官方的文档说明:    

Deferring or Canceling a Transaction

If your app needs to defer or cancel a transaction, you return false. For example, you may need to defer a transaction if the user is in the middle of onboarding, and continue it after onboarding is completed. Or, you may need to cancel a transaction if the user has already unlocked the product they are trying to buy. 

To defer a transaction:

  1. Save the payment to use when the app is ready. The payment already contains information about the product. Do not create a new SKPayment with the same product.

  2. Return false.

  3. After the user is finished with onboarding or other actions that required a deferral, send the saved payment to the payment queue, the same way you would with a normal in-app purchase.

To cancel a transaction:

  1. Return false.

  2. (Optional) Provide feedback to the user. Otherwise, the app’s lack of action after the user taps or clicks Buy in the App Store may seem like a bug.

  在你想苹果的队列中注册监听后,如果用户点击了推荐商品,苹果将启动你的应用,并调用你的方法,等待你的返回

  如果你返回的是YES,苹果会继续完成当前的支付队列,提示用户购买该商品,支付结果同其他的支付回调一样。

  如果你返回的False,苹果将暂停本次购买,需要程序再次触发商品购买才会执行购买流程。

  注:苹果要求你不可以对当前商品进行重新创建订单,需要使用苹果返回的SKPayment 进行队列调用

  如果你返回的是False,你需要将苹果返回的SKPayment 保存,并在合适的时机触发本次购买即可

  • 0x04 如何测试

  苹果的官方文档中给出了沙盒的测试方法:

  itms-services://?action=purchaseIntent&bundleId=com.example.app&productIdentifier=product_id

  可以在同一台手机中使用浏览器访问改地址,将跳转到你的应用中(前提是你安装了应用)。

    

 

转载于:https://www.cnblogs.com/jz512521228/p/7930486.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值