相关文章推荐
英勇无比的仙人掌  ·  SuppressLint Class ...·  2 年前    · 
魁梧的拖把  ·  python 3.x - Pynput - ...·  2 年前    · 

1.在 itunesconnect.apple.com,中配置内购项目,如图右侧有一个(查看公共秘钥)(验证购买时需要使用)

  • 点击加号新建购买项目

  • 根据你们产品的不同选择对应的项目

  • 创建就很简单了,每一项都有介绍这里就不多说了

  • 创建沙箱技术测试员用于内购测试使用

  • 内容可以随便填写,需要注意的是 邮箱 和 密码需要记住(后面需要使用)

使用此 App 的bundleID 唯一标示

  • 创建一个项目,项目的 bundleID 要与 iTunesconnect 中项目的id相同。

Cocoapods 导入 SwiftyStoreKit

  • pod 'SwiftyStoreKit' (内购轮子)
  • pod 'Alamofire' (网络请求轮子)

一切准备就绪-下面代码部分

import SwiftyStoreKit
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
	SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
	    for purchase in purchases {
	        if purchase.transaction.transactionState == .purchased || purchase.transaction.transactionState == .restored {
               if purchase.needsFinishTransaction {
                   // Deliver content from server, then:
                   SwiftyStoreKit.finishTransaction(purchase.transaction)
               print("purchased: \(purchase)")
 	return true
    /// 购买商品
    class func purchase(productID: String,
                        inPurchaseClosure:@escaping ((_ inPurchaseResult: InPurchaseResult)->())) {
        SwiftyStoreKit.purchaseProduct(productID, quantity: 1, atomically: true) { (result) in
            switch result {
            case .success(let purchase):
                print("Purchase Success: \(purchase.productId)")
                // 正式验证
                self.verifyReceipt(service: .production)
                inPurchaseClosure(LFPayTool.InPurchaseResult.success)
            case .error(let error):
                inPurchaseClosure(LFPayTool.InPurchaseResult.failure)
                switch error.code {
                case .unknown:
                    print("Unknown error. Please contact support")
                case .clientInvalid:
                    print("Not allowed to make the payment")
                case .paymentCancelled:
                    break
                case .paymentInvalid:
                    print("The purchase identifier was invalid")
                case .paymentNotAllowed:
                    print("The device is not allowed to make the payment")
                case .storeProductNotAvailable:
                    print("The product is not available in the current storefront")
                case .cloudServicePermissionDenied:
                    print("Access to cloud service information is not allowed")
                case .cloudServiceNetworkConnectionFailed:
                    print("Could not connect to the network")
                case .cloudServiceRevoked:
                    print("User has revoked permission to use this cloud service")
                default:
                    print((error as NSError).localizedDescription)
    /// 本地验证(SwiftyStoreKit 已经写好的类) AppleReceiptValidator
    //  .production 苹果验证  .sandbox 本地验证
    class func verifyReceipt(service: AppleReceiptValidator.VerifyReceiptURLType) {
        //let sharedSecret = ""
        let receiptValidator = AppleReceiptValidator(service: service, sharedSecret: nil)
        SwiftyStoreKit.verifyReceipt(using: receiptValidator) { (result) in
            switch result {
            case .success (let receipt):
                let status: Int = receipt["status"] as! Int
                if status == 21007 {
                    // sandbox验证
                    self.verifyReceipt(service: .sandbox)
                print("receipt:\(receipt)")
                break
            case .error(let error):
                print("error:\(error)")
                break
                    SwiftyStoreKit swift内购1.在 itunesconnect.apple.com,中配置内购项目,如图右侧有一个(查看公共秘钥)(验证购买时需要使用)	点击加号新建购买项目			根据你们产品的不同选择对应的项目			创建就很简单了,每一项都有介绍这里就不多说了			创建沙箱技术测试员用于内购测试使用			内容可以随便填写,需要注意的是 ...
				
SwiftyStoreKit是适用于iOS,tvOS,watchOS,macOS和Mac Catalyst的轻量级In App Purchases框架。 超级易于使用的基于块的API 支持可消费和不可消费的应用内购买 支持免费,可自动更新和不可更新的订阅 在App Store(iOS 11)中开始支持应用程序内购买 支持订阅折扣和优惠 远程收据验证 验证购买,订阅,订阅组 下载Apple托管的内容 兼容iOS,tvOS,watchOS,macOS和Catalyst 想要的贡献 SwiftyStoreKit使大量开发人员可以轻松地集成应用内购买。 但是,该项目现在由社区主导。 我们需要帮助来构建功能并编写测试(请参阅 )。 维护者通缉 作者不再维护这个项目。 如果您想成为维护者,请并进入频道。 展望未来,SwiftyStoreKit应该由社区来为社区制作。 更多信息。 如果您在过去五年中交付了一个应用程序,那么您可能会很高兴。 某些功能(如折扣)仅在新的OS版本上可用,但大多数功能可追溯到: watchOS Mac催化剂
情况之一: 没有添加桥接文件 在Swift工程主目录下新建一个OC类,如果是项目第一次创建OC类,会弹出是否建立Swift-OC的桥接文件的弹窗提示,点击Create Bridging Header 按钮创建即可 手动创建桥接文件,即 Header 文件,名字随意。创建完成之后在项目target下的build setting -> Swift Compiler-General ->Objective-C Bridging Header将上面建立文件的目录设置上去,路径组成格式:项目名/Hea
【课程概括】包含306节超多互动教程,基于新版的Swift和Xcode。手把手讲解大量实用的iOS开发开源类库:BonMot、PKHUD、DZNEmptyDataSet、Alamofire、Moya、Promise、Kingfisher、SnapKit、组件化编程、RxSwift响应式编程、Lottie动画、Hero转场动画、app主题更换、强大的幻灯片、GPUImage图像视频处理、Realm数据库、二维码创建和读取、模拟网络fake数据、自动化压力测试。手把手学习iOS开发中的强大的第三方类库,详细讲解Github中的热门的iOS开发开源项目。助您快速、优雅地解决iOS开发中棘手的业务需求!【课程特点】 1、代码逐行讲解2、语言简洁、精练、瞄准问题的核心所在,减少对思维的干扰,并节省您宝贵的时间3、完美贴心的操作提示,让您的眼睛始终处于操作的焦点位置,不用再满屏找光标4、每个视频都很短小精悍,即方便于您的学习和记忆,也方便日后对功能的检索 【福利来了】获取306节所有课程源码及加入学习群!
class CDIAPManager: NSObject { class func getPurchaseProductList(retur:@escaping (_ productArr:[CDAppBuyInfo]) ->Void){ SwiftyStoreKit.retrieveProductsInfo(["xxx","xxx","xxx"]) { result in
如果在你的 Swift 代码中遇到了 "No such module UIKit" 的错误,通常是因为在你的代码中使用了 UIKit 模块中的类或方法,但是在你的项目中没有导入 UIKit 模块。 要解决这个问题,可以在你的代码文件的顶部添加 import UIKit 语句,然后再次编译你的代码。 例如,如果你的代码文件中使用了 UIButton 类,你可以这样写: import UIKitcla...
1.IGListKit [UICollectionView 框架] -> pod 'IGListKit', '~> 2.0.0 2.Realm [移动端数据库] -> pod 'RealmSwift’ 3.Moya [抽象网络层] -> pod 'Moya', ‘8.0.0’ 4.SwiftyJSON [JSON 解析] -> pod 'SwiftyJSON’ 5.Vale
如题,总是出现奇奇怪怪的报错.下面我结合网友给出的解决方案和我自己解决的方案. 1.pod install完成后还是提示:解决Swift中出现 No such module ‘Moya’ 解决办法是在build phases中的link binary with libraries中先删除pods_xxx.framework,再重新添加一次就好了 2.可能是报错库的版本问题,有ioser在Podfile中为报错库指定了具体版本,问题解决。 3.我的情况,相对来说比较复杂。 开始的时候工程运...