Nell'applicazione: didReceiveRemoteNotification: fetchCompletionHandler, i dati personalizzati vengono trasferiti a didReceiveRemoteNotification, che è un NSDictionary. I dettagli che si desidera recuperare sono probabilmente nella chiave "aps" di userInfo.
func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary!)
{
var notificationDetails: NSDictionary = userInfo.objectForKey("aps") as NSDictionary
}
Quando l'applicazione non viene avviato, è necessario farlo dall'applicazione: didFinishedLaunchWithOptions,
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
if let launchOpts = launchOptions {
var notificationDetails: NSDictionary = launchOpts.objectForKey(UIApplicationLaunchOptionsRemoteNotificationKey) as NSDictionary
}
return true
}
EDIT: Notifica remota Fix sintassi
fonte
2015-04-08 03:27:00
Ok. E cosa faccio dopo? Come ottengo il valore da "notifica"? – Aerofan
Si accede alla proprietà userInfo di UILocalNotification, che è un NSDictionary –
Penso che si stia mescolando Objective-C e Swift con questo codice. – Aerofan