1
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!)
가 호출되지 않는 기능을 등록하지 못했습니다. 다음은 내 코드입니다 :
import UIKit
import PushKit
import Foundation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
var window: UIWindow?
//Tried also to make it local
var voipRegistry:PKPushRegistry?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.registerVoipNotifications()
return true
}
func registerVoipNotifications() {
let mainQueue = dispatch_get_main_queue()
// Create a push registry object
voipRegistry = PKPushRegistry(queue: mainQueue)
// Set the registry's delegate to self
voipRegistry!.delegate = self
// Set the push type to VoIP
voipRegistry!.desiredPushTypes = [PKPushTypeVoIP]
}
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) {
//1. Create the alert controller.
let alert = UIAlertController(title: "VoIPPushTest", message: "Token", preferredStyle: .Alert)
//2. Add the text field. You can configure it however you need.
alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in
textField.text = "got cred"
})
//print out the VoIP token. We will use this to test the nofications.
NSLog("voip token: \(credentials.token)")
let tokenChars = UnsafePointer<CChar>(credentials.token.bytes)
var tokenString = ""
for i in 0..<credentials.token.length {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
print("Device Token:", tokenString)
}
//Other standard app delegate functions below without changes
내가 그렇게
만든 새로운 앱 ID, 프로파일 및 인증
추가 된 배경 기능을 응용 프로그램
에 인증서 문제가 될 수 있음을 읽을코드 서명 : 코드 서명 아이디 - iPhone 배포, 프로비저닝 프로파일 VoIPPushTestProfile
임시 보관 용으로 코드를 보관하고 내보내고 있습니다. 내가 뭘 잘못하고 있니?
정말 고마워요! 다른 사람들이 코드에서 디버그 모드로 작동한다는 것을 알게 될 수도 있습니다. 매번 아카이브 할 필요가 없습니다. – nmnir
퍼펙트 (Perfect), 배포 인증서로 "실행 파일 대기"로 종료 상태에서 앱을 디버그 할 수도 있습니다. – Hasya