asunquan.com

不忘初心 不止于行

职场新人 iOS菜鸟 就职于搜狐畅游 从事iOS/tvOS的SDK开发 对于游戏市场有点点了解 平日和一只小Corgi同吃同睡


iOS内购调研

内购调研

  • 内购类型

    • 官方文档说明
      消耗型 非消耗型 自动续订型 非自动续订型
    购买次数 多次 一次 多次 多次
    票据号显示 一次 每次 每次 每次
    跨设备同步 不同步 系统同步 系统同步 应用同步
    恢复 不可以恢复 系统恢复 系统恢复 应用恢复
    • 结论

      • 消耗型 可以多次购买, Apple ID不会影响到购买关系, 回调SKPaymentTransactionStatePurchased, 可以与游戏角色对应, 几乎不会有任何影响

      • 非消耗型 只能购买一次, 同一Apple ID再次购买会提示: <您已经购买了此项目. 您想免费再获取一次吗?>, 回调SKPaymentTransactionStatePurchased, 此时transactionID, recipt都不同, original_transaction_id相同

      • 自动续订型 可以购买多次, 同一Apple ID在订阅期内, 再次购买会提示: <您目前已订阅此项目>, 回调SKPaymentTransactionStatePurchased, 此时transactionID不同, receipt, original_transaction_id相同

        {
            "latest_receipt" = "ewoJInNpZ25hdHVyZSIgPSAiQXpOdWpMUVhuSmFxMkpWcG1Rdk9EU00xSEh6aDZJSzhZTDY1RGdWN3pjT3FZYjhUbnJ5VkpvYnc2Q1J4NmpOQWJ3ZUdTQk9XMWluQm1tWUFQeXBZRWV4bHVWSGh3NHFZSVZkMGRtUncxWVpuZktYRXlKT0ZiSWJpalUxTXFWVlhVRDJ1VFVsZ1M4WW5CeXJDaW43bGJtY2dMd3JxOWtxeEdRK1hGd3M0UFRiSnlPNy9weGZEaEVxckFENXV5UFR2THNvenFkMHg2M0xya3ppODBNbTFvcHltUDdjQUY5YmQrcllZYlJXaHgweEtDRSsvQk84Sk52WkZ1L1RLMzZxUDFwYU1TVVZlckJxMTBlUGlwVGRFOWd6WmxmRDRxdExzZ3pVY2dlYmdhZklEazdzK1JoUTJWNmRTQmxENkRRY29ROWFVRDhIYUNzcGhmZGc4amI3MFhZNEFBQVdBTUlJRmZEQ0NCR1Nn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WduaW5nLXN0YXR1cyIgPSAiMCI7Cn0=";
            "latest_receipt_info" =     {
                bid = "com.longtugame.demo";
                bvrs = 1;
                "expires_date" = 1500001905000;
                "expires_date_formatted" = "2017-07-14 03:11:45 Etc/GMT";
                "expires_date_formatted_pst" = "2017-07-13 20:11:45 America/Los_Angeles";
                "item_id" = 1258428153;
                "original_purchase_date" = "2017-07-12 09:54:24 Etc/GMT";
                "original_purchase_date_ms" = 1499853264000;
                "original_purchase_date_pst" = "2017-07-12 02:54:24 America/Los_Angeles";
                "original_transaction_id" = 1000000314663763;
                "product_id" = "com.longtugame.demo.d5";
                "purchase_date" = "2017-07-14 03:08:45 Etc/GMT";
                "purchase_date_ms" = 1500001725000;
                "purchase_date_pst" = "2017-07-13 20:08:45 America/Los_Angeles";
                quantity = 1;
                "transaction_id" = 1000000315361723;
                "unique_identifier" = 4b59ff1e94ab8a1d48d856d733cd519d9c60bfbc;
                "unique_vendor_identifier" = "E213C8E8-0754-47BF-AAD7-60246ADE00A7";
                "web_order_line_item_id" = 1000000035615774;
            };
            receipt =     {
                bid = "com.longtugame.demo";
                bvrs = 1;
                "expires_date" = 1500001905503;
                "expires_date_formatted" = "2017-07-14 03:11:45 Etc/GMT";
                "expires_date_formatted_pst" = "2017-07-13 20:11:45 America/Los_Angeles";
                "item_id" = 1258428153;
                "original_purchase_date" = "2017-07-12 09:54:24 Etc/GMT";
                "original_purchase_date_ms" = 1499853264000;
                "original_purchase_date_pst" = "2017-07-12 02:54:24 America/Los_Angeles";
                "original_transaction_id" = 1000000314663763;
                "product_id" = "com.longtugame.demo.d5";
                "purchase_date" = "2017-07-14 03:08:45 Etc/GMT";
                "purchase_date_ms" = 1500001725503;
                "purchase_date_pst" = "2017-07-13 20:08:45 America/Los_Angeles";
                quantity = 1;
                "transaction_id" = 1000000315361723;
                "unique_identifier" = 4b59ff1e94ab8a1d48d856d733cd519d9c60bfbc;
                "unique_vendor_identifier" = "E213C8E8-0754-47BF-AAD7-60246ADE00A7";
                "web_order_line_item_id" = 1000000035615774;
            };
            status = 0;
        }
        
      • 非自动续订型 可以购买多次, 同一Apple ID在订阅期内, 再次购买会提示: <您已经购买了此订阅. 点一下”购买”可续期或延长此项目的时间.>, 回调SKPaymentTransactionStatePurchased, 此时transactionID, recipt, original_transaction_id都不同

        {
            receipt =     {
                bid = "com.longtugame.demo";
                bvrs = 1;
                "item_id" = 1258429565;
                "original_purchase_date" = "2017-07-14 03:06:50 Etc/GMT";
                "original_purchase_date_ms" = 1500001610927;
                "original_purchase_date_pst" = "2017-07-13 20:06:50 America/Los_Angeles";
                "original_transaction_id" = 1000000315361266;
                "product_id" = "com.longtugame.demo.d6";
                "purchase_date" = "2017-07-14 03:06:50 Etc/GMT";
                "purchase_date_ms" = 1500001610927;
                "purchase_date_pst" = "2017-07-13 20:06:50 America/Los_Angeles";
                quantity = 1;
                "transaction_id" = 1000000315361266;
                "unique_identifier" = 4b59ff1e94ab8a1d48d856d733cd519d9c60bfbc;
                "unique_vendor_identifier" = "E213C8E8-0754-47BF-AAD7-60246ADE00A7";
            };
            status = 0;
        }
        

        与自动续订区别

        1. iTunes Connect中不指定订阅协议,应用负责提供这个信息给用
        2. 可以被购买多次,App Store不会自动更新该订阅。应用负责实现订阅更新,检测过期,提示用户重新购买
      • 由于除消耗型购买型都与AppleID一一对应, 并且再次购买时会收到SKPaymentTransactionStatePurchased回调, 所以会造成, 角色A使用Apple ID A充值成功, 再切换到角色B再次使用Apple ID A进行充值, 会不需要扣款就收到支付成功回调, 这里我们虽然可以通过验证票据来检测是不为充值, 但是会导致用户的其他角色不可以再次购买了, 所以, 不适用于月卡, 周卡, 成长红利等对应角色的”可续订型项目”.

  • 推广内购项 iOS11 AppStore新增, 可以通过应用页中点击推广内购项进行内购或是通过搜索推广购买项进行内购, 用户点击推荐内购项时如果用户已经安装了游戏会打开否则会安装

    • iTunes Connect配置 新的配置项App Store 推广(可选), 需上传一张1024*1024像素的宣传图像, 可以配置任意个推广内购项, 但是同时最多只可以推广20个推广内购项, 这些推广内购项可以根据配置排序显示.

    • 注意 在iOS11 Beta测试期间, 已选择的推广内购项会在新AppStore中显示, 但不提供购买功能? 在使用iOS11 SDK构建的版本提交并得到审批后, 必须支持新的回调方法, 推广内购项才会在App Store上显示

      - (BOOL)paymentQueue:(SKPaymentQueue *)queue shouldAddStorePayment:(SKPayment *)payment forProduct:(SKProduct *)product
      
    • 回调方法的返回值是是否进行内购的标识, NO可以中断或是取消此次内购

      • 中断推广内购
        1. 保存payment, payment中包含了product. 无需重新生成SKPayment对象
        2. 返回NO
        3. 在用户完成需要完成的操作时, 将保存的payment添加到支付队列中, 开始正常内购
      • 取消推广内购
        1. 返回NO
        2. (官方文档声明可选项)提供给用户反馈, 否则看起来像是一个bug
    • 测试链接无法打开

      itms-services://?action=purchaseIntent&bundleID=com.longtugame.demo&productIdentifier=com.longtugame.demo.d2
      
    • 结论

      • 推广内购若直接购买存在无法对应游戏角色问题, 所以解决措施有两种
        1. 中断这次交易, 保存payment, 在用户登录后由游戏调用(新)继续执行交易接口, 在该接口实现中添加payment到支付队列中
        2. 取消这次交易, 并回调商品ID, 由游戏记录商品ID, 在用户登录后, 由游戏重新开启一笔交易
      • 存在测试途径问题
最近的文章

iOS开发规范文档

iOS开发规范文档[TOC]工程资源 使用framework作为SDK的呈现形式 设置search path时, 使用相对路径替代绝对路径, 使用输出SDK目录路径替代本机DerivedData路径 资源bundle文件夹不需要进行编译 图片资源命名规则: 模块_控件类型_功能_状态@几倍图.图片类型命名规则 禁止使用拼音命名, 要使用正确的英文拼写进行命名 命名使用驼峰命名法, 类名使用大驼峰命名法, 其余使用小驼峰命名法 属性, 方法, 参数, 变量, 常量等...…

iOS开发继续阅读
更早的文章

面试经历之TalkingData

面试经历之TalkingData之前收到TalkingData的面试邀约, 今天下午去面试了下, 记录下今天的面试经历.约的是下午两点半, 地点在东直门京投轻轨大厦, 地理位置很好, 从东直门公交枢纽上来就有电梯上楼, 6层出电梯就能看到, 前台的门是感应门, 不过我走到感应门前门没有开让我误以为是推的门了, 很囧…进去之后简单登记了下, 前台MM给了一张表让我去填, 填了一会就填完了, 交给前台MM之后等了几分钟第一个面试官来了.一面, 主要是针对简历问了下功能, 然后针对技术的实现问了...…

数据结构继续阅读