我该如何实现苹果推送通知? [英] How can i implement apple Push Notification ??

查看:131
本文介绍了我该如何实现苹果推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone开发的新手,我想在我的应用程序中实现推送通知。我根本不知道。任何人都提供示例代码。

i am new in iphone development,i want to implement push Notification in my application. i have no idea about that. anyone give sample code.

推荐答案

首先,您必须租用或拥有一台负责与Apple的APNS服务器通信的服务器。是的,当您向应用的用户推送通知时,您的服务器必须首先将其推送到Apple并让Apple代表您将这些通知转发给特定用户。

Firstly, you have to either rent or own a server that is responsible for communicating with Apple's APNS servers. Yes, when pushing notifications to your app's users, your server has to first push it to Apple and have Apple transfer those notifications to specific users on your behalf.

其次,在AppDelegate的.m文件中覆盖并实现以下方法:

And second, override and implement the following methods in your AppDelegate's .m file:

    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {  
    - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {  
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    //You probably already implemented this one
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

在将应用投入生产之前,使用Apple的Sandbox服务器测试您的代码和服务器。

And test your code and your server with Apple's Sandbox server before you put your app into production.

这篇关于我该如何实现苹果推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆