中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgiPhone开发教程之处理常见任务(2)启用推送通知通知的类型标记类型声音类型提醒类型使你的程序具有无障碍性重要提示提供搜索功能并显示搜索结果利用用户的位置中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgWhenyouregisteryourapplicationwithApplePushNotificationService,youcanarrangetoalertuserswhennewdataarrives,evenifyourapplicationisn’trunning.Whenadevicereceivesamessageforanapplicationthatisn’trunning,itcannotifytheuserby:当你为你的应用程序注册苹果推送通知服务时后,当接收到新的数据后,即可安排提醒予以用户(提醒新数据),即使你的应用程序没有运行。当设备接收到某个未运行应用程序的信息时,它可以这样通知用户:iPhone开发教程之启用推送通知中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgUpdatingabadgeontheapplication’sHomescreenicon在应用程序的主屏幕图标上显示徽章Playinganalertsound播放提醒声Displayinganalertmessage显示一个提醒信息orsomecombinationofthese.Theusermightrespondbystartingtheapplicationtomanagethenewdataormerelyacknowledgingitsarrival.(Tolearnhowtohandlepushnotificationsincode,seeApplePushNotificationServiceProgrammingGuide.)或者任意组合上述的通知方式。用户对通知的反应可能有,启动此应用程序去管理一下新数据,或者只是了解通知的到达(而不采取任何操作)。(要了解如何用代码处理推送通知,参见苹果推送通知服务编程指南。)iPhone开发教程中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgNote:Deliveryofpushnotificationsisnotguaranteed.Also,userscanrefusetoreceivenotificationssystem-wide.Pushnotificationsareintendedtonotifyusersofnewdata,nottodelivercriticaldatatoyourapplication.注意:推送通知的发送不是有保证的。同时,用户可以全系统地拒绝接收通知。推送通知的目的是通知用户有新数据,并不会向你的应用程序写入重要数据。iPhone开发教程中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgTheNotificationssectioninthebuilt-inSettingsapplicationhostspushnotificationsettingsforeveryapplicationthatregistersfortheApplePushNotificationService.Foreachapplication,iPhoneOSprovidessettingsforuserstoallowordisallowbadging,sounds,andalertmessages.内置的设置应用程序中的通知设置部分主导着推送通知的设置,它对每个注册了苹果推送通知服务的应用程序都提供了设置。对于每个应用程序,iPhone操作系统都提供给用户允许或不允许,标记,声音,提醒的三种方式的通知。iPhone开发教程中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgTakesometimetothinkaboutthetypesofeventsforwhichuserswouldappreciatenotification.Anotificationshouldgiveusersuseful,actionableinformationtheywanttoreceive,evenwhenthey’renotusingyourapplication.请花一些时间想想什么类型事件的通知是用户希望的。通知应给予用户那些有用的,可付诸操作的信息,即使他们没有使用你的应用程序。iPhone开发教程中国移动互联网研发培训专家www.embedtrain.orgwww.mobiletrain.orgAfteryou’veidentifiedtheeventsyourusersarelikelytocareabout,youshouldalsoallowuserstodecidewhicheventsshouldgeneratewhattypeofnotification,ifany.Ifyoudon’tallowuserstocustomizethepushnotificationexperienceinyourapplication,you’reliabletopesteruserswithnotificationsthey’renotinterestedin.当你已经确定应用程序的哪些事件用户可能会关心之后,如果有的话,你也应该允许你的用户决定哪些事件使用什么类型的通知。如果你不允许用户自定义应用程序中的推送通知的体验,你就容易让用户陷入与他们不感兴趣的通知的纠缠之中。iPhone开发教程中国移动互联网研发培训专家www.embedtrain.orgw...