有没有可能在没有iPhone应用程序的情况下测试苹果推送通知服务?(在windows上创建仿真器?)
如果不是,我怎么测试它呢?有没有一个免费的示例应用程序编译来做这件事?
我创建了服务器提供程序,但我需要测试其功能。
发布于 2012-12-14 01:48:13
你不能测试真正的推送通知。然而,你可以通过编程创建一个模拟推送通知并手动触发你的AppDelegate的- application:application didReceiveRemoteNotification:notification方法来测试你的应用对模拟推送通知的响应。
要从不同的类(如UIViewController)触发此操作:
[[[UIApplication sharedApplication] delegate]
application:[UIApplication sharedApplication]
didReceiveRemoteNotification:testNotification];testNotification应该具有与实际通知相同的格式,即包含属性列表对象和NSNull的NSDictionary。
下面是如何提供上述testNotification的示例:
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"];这应该会创建一个合理的通知NSDictionary来使用。
https://stackoverflow.com/questions/1080556
复制相似问题