Vous ne pouvez pas tester les notifications push réelles. Cependant,, vous pouvez tester la réponse de votre application à une notification push simulée en créant un déclencheur par programmation et manuellement de la méthode - application:application didReceiveRemoteNotification:notification
de votre AppDelegate.
Pour déclencher ce à partir d'une autre classe (comme un UIViewController):
[[[UIApplication sharedApplication] delegate]
application:[UIApplication sharedApplication]
didReceiveRemoteNotification:testNotification];
Le testNotification devrait avoir le même format comme une véritable notification, à savoir un NSDictionary contenant des objets de la liste des biens ainsi que NSNull.
Voici un exemple de la façon de fournir les testNotification
ci-dessus:
NSMutableDictionary *notification = [[NSMutableDictionary alloc] init];
[notification setValue:@"Test" forKey:@"alert"];
[notification setValue:@"default" forKey:@"sound"];
NSMutableDictionary *testNotification = [[NSMutableDictionary alloc] init];
[testNotification setValue:notification forKey:@"aps"];
Cela devrait créer un NSDictionary de notification raisonnable de travailler.
Il est temps de mettre à jour la meilleure réponse. Bibliothèque de ma réponse est très utile, merci 'acoomans' pour ça! – kaspartus