You cannot test real push notifications. However, you can test your applicationโs response to a simulated push notification by creating one programmatic and manual launch of your AppDelegate method - application:application didReceiveRemoteNotification:notification .
To initiate this from another class (e.g. UIViewController):
[[[UIApplication sharedApplication] delegate] application:[UIApplication sharedApplication] didReceiveRemoteNotification:testNotification];
TestNotification must be in the same format as the real notification, namely NSDictionary containing the properties list objects plus NSNull.
Here is an example of how to provide testNotification above:
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"];
This should create a reasonable NSDictionary notification to work with.
Jamon Holmgren Dec 13 '12 at 17:48 2012-12-13 17:48
source share