Die FunktioniOS VoIP Push - Fehlgeschlagen
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!)
Ist das nicht dazu aufgerufen, registrieren. Hier ist mein Code:
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
ich gelesen, dass es sich um ein Zertifikat Problem
Added Hintergrund-Funktionen der App
Erstellt neue App-ID, Profil und Zertifikat
- so sein kann
Unterschreiben des Codes mit: Codesignierung Identität - iPhone Verteilung, Bereitstellungsprofil VoIPPushTestProfile
Ich archiviere den Code und exportiere für Ad-hoc-Bereitstellung. Was mache ich falsch ???
Vielen Dank! Es kann anderen helfen zu wissen, dass es auch im Debug-Modus von Code funktioniert - keine Notwendigkeit, jedes Mal zu archivieren. – nmnir
Perfekt, Sie können die App auch im Kill-Status debuggen, indem Sie auf "Wartet darauf, dass die ausführbare Datei gestartet wird" mit Verteilungszertifikaten klicken. – Hasya