Vorrei estendere la risposta di Sourav Gupta un po '. Una volta che hai fatto fino a ciò che Sourav ha spiegato, devi implementare i delegati per ricevere le azioni di notifica push. I delegati sono,
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler {
// Handle actions of local notifications here. You can identify the action by using "identifier" and perform appropriate operations
if(completionHandler != nil) //Finally call completion handler if its not nil
completionHandler();
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler {
// Handle actions of remote notifications here. You can identify the action by using "identifier" and perform appropriate operations
if(completionHandler != nil) //Finally call completion handler if its not nil
completionHandler();
}
è possibile fare riferimento campione notifica payload remoto qui iOS8 Push notification Payload
fonte
2014-09-29 10:44:54
La ringrazio molto @Sourav Gupta. Ma per quanto riguarda la notifica remota? –
Lo stesso codice funzionerà anche per la notifica remota. Hai solo bisogno di aggiungere la chiave "categoria" nel payload push. la chiave "categoria" dovrebbe avere lo stesso valore identificativo che stai definendo nel tuo codice. –
Sorry Sourav Non capisco il concetto. Potresti per favore elaborare la tua risposta? Quando invio una notifica remota, il carico utile dovrebbe contenere tutti i dettagli? –