Non riesco a ricevere il token del dispositivo durante la registrazione per le notifiche remote. Ricevo il messaggio di avviso "Do you want to allow App X to be able to send you notificaitons"
, ma quando lo accetto, la funzione didRegisterForRemoteNotifications
non viene chiamata. Ho provato il seguente codice.Come ottenere un token dispositivo durante la registrazione per le notifiche remote in Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var types: UIUserNotificationType = UIUserNotificationType.Badge |
UIUserNotificationType.Alert |
UIUserNotificationType.Sound
var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
var characterSet: NSCharacterSet = NSCharacterSet(charactersInString: "<>")
var deviceTokenString: String = (deviceToken.description as NSString)
.stringByTrimmingCharactersInSet(characterSet)
.stringByReplacingOccurrencesOfString(" ", withString: "") as String
println(deviceTokenString)
}
Il mio profilo di approvvigionamento e certificati sono in ordine.
Qualcun altro ha avuto questo problema?
Avete implementato la richiamata per quando la registrazione non riesce e vedere se questo viene chiamato? – dan
Ho applicato il metodo delegate durante la registrazione non riesce ma non sta chiamando –
Ho avuto questo stesso problema lo hai mai capito? –