我怎样才能实现苹果推送通知?? [英] How can i implement apple Push Notification ??

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

问题描述

我是 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天全站免登陆