如何在 APNS 中发送设备令牌
我已经实现了以下代码但没有获得设备令牌?
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"deviceToken: %@", deviceToken);
}
I Have implemented following code but not getting the Device Token?
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"deviceToken: %@", deviceToken);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您还没有这样做,您应该在
didFinishLaunchingWithOptions
中调用registerForRemoteNotificationTypes
。大致如下:您还应该有一个在注册失败时调用的
didFailToRegisterForRemoteNotificationsWithError
方法。它得到的 NSerror 应该告诉你更多关于它可能失败的原因。If you don't already, you should have a call to
registerForRemoteNotificationTypes
in yourdidFinishLaunchingWithOptions
. Something along the lines of:You should also have a
didFailToRegisterForRemoteNotificationsWithError
method that gets called if registration fails. The NSerror it gets should tell you more about why it might be failing.您正在模拟器内部尝试吗?
推送通知和相关的 appdelagate 事件在模拟器上不起作用。
如果您正在使用该设备,
确保您的应用程序的捆绑包标识符必须与您在 iphone 预配置原型上创建 AppID 期间定义的推送 ssl 捆绑包标识符相同。
Are you trying inside of the simulator ?
Push notification and related appdelagate events doesn't work on simulator.
If you are using the device,
Make sure that bundle identifier of your application must be same with your push ssl bundle identitifier which you defined during creating AppID on iphone privisioning protal.
为了向 APN 注册您的设备,您首先必须调用
这通常是在您的 AppDelegate 中编写的(在 didFinishLaunching 中)。
然后确保您已经实现了它,
它为您提供了设备令牌,并
为您提供了代码可能遇到的错误。
For registering your device with APNs, you will first have to call
this is usually written in your AppDelegate (in didFinishLaunching ).
Then make sure you have implemented the
which provides you with the device token and
which gives you the error your code might have encountered.