SKPaymentTransactionObserver 的应用程序委托设置

Sla*_*ast 1 ios swift

我已经设置了一个PurchaseViewController工作正常的程序,除了多个应用程序商店登录,我意识到这是SKPaymentQueue.defaultQueue().addTransactionObserver(self). 我需要将其插入到函数Appdelegate的类中DidFinishLaunchingWithOptions。当我这样做时:

import UIKit
import StoreKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, SKPaymentTransactionObserver {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{        
    UINavigationBar.appearance().barTintColor = UIColor(red: 0/255.0, green: 115/255.0, blue: 158/255.0, alpha: 1.0)
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]

    SKPaymentQueue.defaultQueue().addTransactionObserver(self)

    // Override point for customization after application launch.
    return true
}
Run Code Online (Sandbox Code Playgroud)

我明白了Type Appdelegate does not conform to protocol "SKPaymentTransactionObserver

有人可以指出我哪里出错了吗?

Viv*_*kar 5

您已声明AppDelegate符合SKPaymentTransactionObserver,但尚未实现 必需的paymentQueue(_:updatedTransactions:)方法。这就是 Xcode 不高兴的原因。

在你的AppDelegate实现中,Xcode 将停止抱怨。

这里