实施苹果推送通知的步骤是什么?

发布于 2024-08-18 21:22:48 字数 742 浏览 2 评论 0原文

我是这个主题的新手,需要一些指导来在我的应用程序中实现 Apple 推送通知。我已经创建了我的 appID,并为其配置了 Apple 推送通知。我已经下载了配置文件并在 iPhone 上安装了该应用程序。我还编写了Apple文档提供的以下代码

- (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 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...

Thanx in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽你眉间 2024-08-25 21:22:48

当您注册来自设备的通知时,您需要告诉您的服务器Apple返回的设备令牌,以便服务器在告诉Apple服务器有新通知时可以提供相同的令牌和应用程序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?

把梦留给海 2024-08-25 21:22:48

如果您想知道应用程序位于前台时通知何时到达,您还必须监听 didReceiveRemoteNotification 。当用户阅读发送的通知后,您可能还想清除应用程序图标上设置的徽章编号。

You also got to listen to didReceiveRemoteNotification in case you want to know when notifications arrive also when the app is in foreground. You might also want to clear the badge number set on the app icon when the user has read the notification it was sent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文