2016-04-09 3 views
0

SKPaymentQueue.defaultQueue().addTransactionObserver(self)が実現した複数のアプリストアのログインを除いて、正常に動作しているPurchaseViewControllerをセットアップしました。 DidFinishLaunchingWithOptionsクラスのAppdelegateクラスに挿入する必要があります。私はこれを行うと: SKPaymentTransactionObserverのApplelegate設定

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 
} 

は私が Type Appdelegate does not conform to protocol "SKPaymentTransactionObserverを取得します。

誰かが私が間違っている場所を指摘してくれる?

+0

おそらく欠落しているデリゲートメソッドですか? – LoVo

答えて

4

あなたはSKPaymentTransactionObserverに準拠するために、あなたのAppDelegateを宣言しているが、あなたは必要方法である paymentQueue(_:updatedTransactions:)を実装していません。だからこそXcodeは満足していません。

あなたのAppDelegateにそれを実装すると、Xcodeは不平を言います。

hereを参照してください。

+0

はい、paymentQueue(_:updatedTransactions :)メソッドはすでに別のviewControllerクラスに実装されています。あなたはシングルトンを作ることを提案しますか?それはここで受け入れられる手続きですか? – user2986119

+0

ここでデリゲートメソッドを実装していない場合は、AppDelegateから 'SKPaymentTransactionObserver'を削除してください。また、アプリ内購入と代理人を管理するためのヘルパークラスを構築することも賢明です。シングルトンである必要はありませんが、どちらも害はありません。 –

0

オクラホマので、ときアプリが起動し、私のPurchaseViewControllerで関数を作成し、その後

import UIKit 

**let PVC_Share = PurchaseViewController.PVC_share** 


@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

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()] 


    **PVC_Share.paymentObserver()** 

    // Override point for customization after application launch. 
    return true 
} 

...

がPurchaseViewControllerにアクセスするためのシングルトンを作成した.....それが仕事を得るために管理それはtransactionObserver

PurchaseViewControllerを発射:

今、私はログインのための迷惑な複数のポップアップを取得していないよ。 ご協力いただきありがとうございます!

関連する問題