繁体   English   中英

委托方法未调用

[英]Delegate method not being called

我已经写了一些方法在我们的应用程序中实现推送通知(voip pushkit)。 在我创建的用于测试代码的Xcode项目中,它可以完美地工作。 当我将代码复制到主项目中时,没有执行某些委托方法...

import UIKit
import PushKit
import AVFoundation
import CoreData
import Meteor
import Stripe

let Meteor = METDDPClient(serverURL: NSURL(string: "http://example.com/websocket")!)


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {

    var voipRegistry:PKPushRegistry!
    let designAssets = DesignAssets()
    let stripePublishableKey: String = "xxxxx"
    var ringing: AVAudioPlayer!
    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        registerForVoIPPushes()
        return true
    }



    func registerForVoIPPushes() {

        let notificationSettings: UIUserNotificationSettings! = UIApplication.sharedApplication().currentUserNotificationSettings()

        if (notificationSettings.types == UIUserNotificationType.None) {
            let notificationTypes: UIUserNotificationType = [.Badge, .Sound, .Alert]
            let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
            UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
        }

        voipRegistry = PKPushRegistry(queue: dispatch_get_main_queue())
        voipRegistry.delegate = self
        voipRegistry.desiredPushTypes = Set([PKPushTypeVoIP])
        print("VOIP Push registered")
    }


    func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) {
        let voipToken: String! = credentials.token.description
        print("\n\n##### PushKit credential: \n\n", voipToken)
    }

永远不会评估最后一个方法(didUpdatePushCredentials),永远不会将令牌输出到控制台...为什么? 在测试项目中,它工作得很好。

Duuuhhh,忘了添加后台模式

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM