问题描述
我是这个主题的新手,需要一些指导来在我的应用程序中实现 Apple 推送通知.我已经创建了我的 appID 并为其配置了 Apple 推送通知.我已经下载了配置文件并在 iPhone 上安装了该应用程序.我还编写了Apple文档提供的以下代码
I am new to this topic and require some guidance in implementing Apple Push Notification in my application. I have created my appID and also configured Apple Push Notification for the same. I have downloaded the provisioning profile and installed the app on the iphone. I have also written the following code provided by Apple documentation
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
{
const void *devTokenBytes = [devToken bytes];
NSLog(@"devToken=%@",devTokenBytes);
//self.registered = YES;
//[self sendProviderDeviceToken:devTokenBytes]; // custom method
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSLog(@"Error in registration. Error: %@", err);
}
我想知道我必须在服务器端写什么.当我运行代码时,它说设备未注册.如何为推送通知注册我的应用程序.
I want to know what I have to write on the server side. When I run the code it says that the device is not registered. How can I register my application for the push notification.
谁能帮我解决这个问题...
Can anyone help me with this...
任何代码都会非常有帮助...
Any code will be very helpful...
提前谢谢...
推荐答案
当你注册设备的通知时,你需要告诉你的服务器苹果返回的设备令牌,这样服务器才能呈现相同的令牌和应用程序id 当它告诉苹果服务器有新通知时.你这样做了吗?我相信设备令牌可能会在您每次注册时更改,因此您需要在您的服务器上跟踪它(并每次都告诉服务器).
You need to tell your server about the device token returned by Apple when you register for notifications from the device, so that the server can present the same token and app id when it tells the apple server that there's a new notification. Have you done that? I believe the device token could change each time you register, so you'll need to keep track of that on your server (and tell the server each time).
您已经展示了设备注册中涉及的回调,但您是否真的调用了注册方法本身?
You've shown the callbacks involved in device registration, but have you actually called the registration method itself?
这篇关于实现苹果推送通知的步骤是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!