模拟器上的设备令牌请求没有响应
我是 iPhone 技术的新手,现在我正在使用一个需要实现推送通知的应用程序。
我点击了链接:
http://mobiforge.com/ Development/story/programming-apple-push-notification-services#comment-7850
另外,使用了以下代码:
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(str);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
for (id key in userInfo)
{
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}
事情是,当我运行程序时,我应该在调试器窗口中获取设备令牌,按照代码,相反我收到如下错误:
“注册时出错。错误:错误 域=NSCocoaErrorDomain 代码=3010 “远程通知不是 模拟器中支持” 用户信息=0x6e055a0 {NSLocalizedDescription=远程 不支持通知 模拟器}“
我应该如何解决这个问题?
请帮助我。
谢谢。
I am newbie to iphone technology,right now i m working with an application where i need to implement push notification.
I followed the link :
http://mobiforge.com/developing/story/programming-apple-push-notification-services#comment-7850
Also,Used the following code :
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(str);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
for (id key in userInfo)
{
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}
Thing is,when i run the program,i should get device token in the debugger window,as per the code,instead i am getting error like :
" Error in registration. Error: Error
Domain=NSCocoaErrorDomain Code=3010
"remote notifications are not
supported in the simulator"
UserInfo=0x6e055a0
{NSLocalizedDescription=remote
notifications are not supported in the
simulator} "
How should i solve this problem?
Kindly help me out.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为模拟器不支持它......在示例中,它在控制台中显示设备标识符。控制台正在显示来自设备的反馈。获取信息的不是控制台,而是发回信息的设备。因此,控制台在您的 Mac 上显示信息并不意味着您的 Mac 能够直接获取该信息。有时它必须由设备发送。尝试在设备上运行它。
Because the simulator doesn't support it... In the example it displays the device identifier in the console. The console is displaying the feedback from the device. It isn't the console that is getting the information, but the device sending the information back. So, just because the console displays information on your Mac doesn't mean your Mac is capable of directly getting that information. Sometimes it must be sent by the device. Try running it on a device.
错误消息是不言自明的,您应该尝试在真实设备上而不是模拟器上调试应用程序,因为模拟器不支持接收推送通知。
The error message is self explaining, you should try to debug the app on real device not on the simulator, as push notifications are not supported to be received on the simulators.