parse :[英]pɑ:z[美]pɑ:rs vt.从语法上描述或分析(词句等)
用Parse作为推送的服务端,所以前提是你的应用已经设置完关于推送的相关证书。Parse还可以实现客户端之间的推送(即时消息),本文只简单介绍服务器->客户端的推送实现。
一.访问Parse.com ,点击右上角的Sign Up创建一个账号。账号创建好后会要求你创建你的第一个app名称,随意取名就好。
二. Dashboard -> 你的app名称(一种创建的)-> setting -> Push notifications :将注册证书过程中生成的.p12文件添加到Apple Push Certificates中
三.配置Parse服务,页面里有相关说明 www.parse.com/apps/quickstart?onboard=#parse_push/ios/existing
1.Install the SDK
1)Download & unzip the SDK(下载parse的sdk)
Make sure you are using the latest version of Xcode(4.6+) and targeting iOS 5.0 or higher(保证xcode版本4.6+,真机版本5.0 或以上)
2) Add the SDK to your app (将sdk添加到你的app工程中)
Drag the Parse.framework folder you downloaded into your Xcode project folder target.
Make sure the "Copy items to destination's group folder" checkbox is checked(直接拖动Parse.framework到你的工程目录中,确保"Copy items to destination's group folder"被勾选)
3) Add the dependencies (添加一些framework)
(Click on Targets -> Your app name -> and then the 'Build Phases' tab.
Expand 'Link Binary With Libraties' as shown.)
4)在AppDelegate.m中添加
#import <Parse/Parse.h>
5)在方法 application:didFinishLaunchingWithOptions: 中添加
[Parse setApplicationId:@"" clientKey:@""];
Dashboard -> 你的app名称(一种创建的)-> setting -> Application keys : 将你的ApplicationId 和 clientKey 填入这里([Parse setApplicationId:@"" clientKey:@""])
6)在didFinishLaunchingWithOptions记得加入开启推送服务的语句
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge| UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound];
7)Store the device token and handle the UI for notifications by adding the following to your main app delegate:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // Store the deviceToken in the current installation and save it to Parse. PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation setDeviceTokenFromData:deviceToken]; [currentInstallation saveInBackground]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [PFPush handlePush:userInfo]; }

浙公网安备 33010602011771号