`
ydbc
  • 浏览: 719788 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

iOS 开发:应用内实现 更新提醒

 
阅读更多
目前绝大多数的应用都可以实现应用更新后,打开应用就能得到更新提醒。这有利于用户的更新。
关于如何实现的方式,很多人希望Xcode本身能够提供相应的API来实现对应用版本的查找,但就目前来看,还没有这样的API。因此,目前的解决办法有两种:
1、自己架设服务器,当应用更新后,就在自己的服务器中更新版本信息,然后让应用连接服务器来查找版本信息,与当前应用版本核对,如果更新则提示
2、利用App Store的Search-api,通过相应的api,request可以得到相应的应用信息,关键是JSON格式的,因此就很方面对版本信息进行提取然后比对。下面是网址:
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
可以看到,只要使用https://itunes.apple.com/lookup?id=595176741 这样的url进行request,id要换成所在应用的id,然后就可以得到JSON格式的信息。
下面是以应用 3D量角器为例可以得到如下JSON信息:
{
"resultCount":1,
"results": [
{"kind":"software", "features":["iosUniversal"], "supportedDevices":["iPodTouchourthGen", "iPad2Wifi", "iPad23G", "iPhone4"], "isGameCenterEnabled":false, "artistViewUrl":"https://itunes.apple.com/us/artist/hongkun-song/id595176744?uo=4", "artworkUrl60":"http://a86.phobos.apple.com/us/r1000/091/Purple2/v4/0a/db/51/0adb5130-5d18-0b98-d1cc-3ddd114b10d5/icon57_57.png",
"screenshotUrls":["http://a1960.phobos.apple.com/us/r1000/108/Purple/v4/ea/52/80/ea52802a-c7d9-1dca-defe-937fb61bbc3e/mzl.ghupvxyw.png", "http://a1740.phobos.apple.com/us/r1000/110/Purple2/v4/58/40/64/584064d8-1d3b-6704-3bf7-3b1c771d25c1/mzl.ydpovfzk.png", "http://a180.phobos.apple.com/us/r1000/100/Purple2/v4/22/01/90/22019008-314d-07e7-49e4-2359983058c0/mzl.hefjpqiw.png", "http://a1862.phobos.apple.com/us/r1000/107/Purple/v4/ee/23/a6/ee23a69f-768f-5fe8-9444-298a26330faa/mzl.sxiofdqt.png", "http://a980.phobos.apple.com/us/r1000/102/Purple/v4/cd/2c/9f/cd2c9fff-8dac-b75d-f260-c223ea8d2b33/mzl.trozlblw.png"],
"ipadScreenshotUrls":["http://a651.phobos.apple.com/us/r1000/079/Purple/v4/e9/ab/55/e9ab55ab-6b7c-04ab-034e-833c113be412/mzl.ganeacuj.1024x1024-65.jpg", "http://a247.phobos.apple.com/us/r1000/107/Purple/v4/f3/87/60/f3876038-162a-7df4-87e5-54b6a5b14b78/mzl.vxycagic.1024x1024-65.jpg", "http://a831.phobos.apple.com/us/r1000/093/Purple2/v4/8b/b3/77/8bb37753-e3d5-9f45-ecfb-bf09cdb660f0/mzl.ncygstwb.1024x1024-65.jpg", "http://a376.phobos.apple.com/us/r1000/078/Purple/v4/f3/4e/36/f34e362f-dee0-0903-436e-034ba94a6f79/mzl.ecchwkyv.1024x1024-65.jpg", "http://a1624.phobos.apple.com/us/r1000/079/Purple/v4/db/12/9d/db129d6b-107b-fa80-f472-a8c7809ef513/mzl.xjmeijfn.1024x1024-65.jpg"], "artworkUrl512":"http://a1435.phobos.apple.com/us/r1000/076/Purple/v4/d1/36/f5/d136f5d0-3962-9ba1-95b2-3ca0ba3be9ec/mzl.zzqaoikx.jpg", "artistId":595176744, "artistName":"Hongkun Song", "price":1.99, "version":"2.0",
"description":"Measure actual angles from a distance? This magical App makes impossible happen!\n\nJust throw your plastic protractor away if you have an iPhone! I think you would never have to use traditional protractors any more! Since here is a much better tool for you to measure angles, that is your iOS device and of course, with the amazing app 3D Protractor!\n\n3D Protractor! A super tool for you to measure all kinds of angles in the 3D space by moving and rotating your iOS device or using the camera!\n\nDon\u2019t limit your imagination of measuring angles to just measuring the angle between two lines on a plane! This was an old thinking. 3D Protractor breaks it! In fact,it is so powerful that it can do following five jobs:\n1,Line-Line Angle Measurement. It can measure the angle of any two lines in the space,include the angle on a plane.\n2,Slope Angle Measurement. \n3,Dihedral Angle Measurement.\n4,Line-Face Angle Measurement.\n\n5,Camera Angle Measurement. It is a super cool feature! It can measure actual angles of any objects in front by the device's camera. Unbelievable! Actual angle! \n\nYou might feel a little bit confused at first after reading the above professional descriptions. This App uses 3D models to make it really easy for you to understand and use.\nEveryone can use it. Students can use it to do their homework. Teachers can use it to teach geometry especially solid geometry, which makes a really good teaching tool. Engineers can use it to measure any angles they need to know at work. And of course, there are many many more usages in our daily life.\n\n3D Protractor! Re-invention of protractor! \nA great app to make measuring angle easy and more accurate! \nA great app to change the world of angle measurement!\n\nPS. 1、If you measure an angle in a long time,the precision may be lower.\n2、This version has no Ads!", "currency":"USD", "genres":["Utilities", "Education"], "genreIds":["6002", "6017"], "releaseDate":"2013-01-26T07:54:39Z", "sellerName":"Hongkun Song", "bundleId":"com.manmanlai.-D-Protractor", "trackId":595176741, "trackName":"3D Protractor", "primaryGenreName":"Utilities", "primaryGenreId":6002,
"releaseNotes":"1、Add Camera Angle Measurement Feature; \nIt is a super cool feature! It can measure actual angles of any objects in front by the device's camera. Unbelievable! Actual angle!\n2、Add radian number display; \nTap the number, then you would see the transition between degree and radian number. \n3、Add traditional chinese version; \n4、Fix some bugs;", "formattedPrice":"$1.99", "wrapperType":"software", "trackCensoredName":"3D Protractor", "trackViewUrl":"https://itunes.apple.com/us/app/3d-protractor/id595176741?mt=8&uo=4", "contentAdvisoryRating":"4+", "artworkUrl100":"http://a1435.phobos.apple.com/us/r1000/076/Purple/v4/d1/36/f5/d136f5d0-3962-9ba1-95b2-3ca0ba3be9ec/mzl.zzqaoikx.jpg", "languageCodesISO2A":["ZH", "EN"], "fileSizeBytes":"14633609", "averageUserRatingForCurrentVersion":5.0, "userRatingCountForCurrentVersion":2, "trackContentRating":"4+", "averageUserRating":4.5, "userRatingCount":8}]
}
可以看出,包括更新的内容都有,这就非常好办了。具体的实现方式这里写一下获取的方法:
[cpp]
[plain]
<span style="font-size:24px;">NSString *query = [NSString stringWithFormat:@"https://itunes.apple.com/lookup?id=%@", AppID];
query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error] : nil;</span>
获取了NSDictionary 的results,之后一切都好办。代码中特地加入UTF8String编码,不用也可以。当然,网页上说All JSON results are encoded as UTF-8。
另外,要获得App的版本号,如下
App版本: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
App Build版本: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
分享到:
评论

相关推荐

    企业级iOS应用开发实战(全部章节)

    实战篇(18~19章)以迭代的方式讲解了两个综合案例的完整实现过程,既融合了前面的理论知识,又展现了企业级iOS应用开发的流程和方法。企业级ios应用开发实战具有如下特点:1、主题明确,以“iOS”和“企业开发”为...

    iOS 9开发指南 [管蕾 编著] 2015年版(2-2)

    全书共39章,循序渐进地讲解了iOS 9应用开发的基本知识。本书从搭建开发环境讲起,依次讲解了Objective-C语言基础,Swift语言基础,Cocoa Touch,Xcode Interface Builder界面开发,使用Xcode编写MVC程序,文本框和...

    企业级iOS应用开发实战(高清版)

    实战篇(18~19章)以迭代的方式讲解了两个综合案例的完整实现过程,既融合了前面的理论知识,又展现了企业级iOS应用开发的流程和方法。企业级ios应用开发实战具有如下特点:1、主题明确,以“iOS”和“企业开发”为...

    iOS 8开发指南(全书源码).rar

    C语言基础、Swift语言基础、CocoaTouch、XcodeInterfaceBuilder界面开发、使用Xcode编写MVC程序、文本框和文本视图、按钮和标签、滑块、步进和图像、使用开关控件和分段控件、Web视图控件和可滚动视图控件、提醒和...

    一步一步学习IOS6

    第二部分:iOS编程基础:Hello World应用程序如何工作的? 第三部分:iOS 编程向导:创建一个简单的表视图(Table View)应用程序 第四部分:定制UITableView表视图单元格 第五部分:如何处理UITableView中的行选择 ...

    一步一步学习_iOS_6_编程(第四版)

    第二部分:iOS编程基础:Hello World应用程序如何工作的? 第三部分:iOS 编程向导:创建一个简单的表视图(Table View)应用程序 第四部分:定制UITableView表视图单元格 第五部分:如何处理UITableView中的行选择 ...

    iOS开发教程(从0到AppStore上架)

    C语言基础、Swift语言基础、CocoaTouch、XcodeInterfaceBuilder界面开发、使用Xcode编写MVC程序、文本框和文本视图、按钮和标签、滑块、步进和图像、使用开关控件和分段控件、Web视图控件和可滚动视图控件、提醒和...

    iOS 8开发指南3~13源码

    C语言基础、Swift语言基础、CocoaTouch、XcodeInterfaceBuilder界面开发、使用Xcode编写MVC程序、文本框和文本视图、按钮和标签、滑块、步进和图像、使用开关控件和分段控件、Web视图控件和可滚动视图控件、提醒和...

    iOS 8开发指南14~23源码.rar

    C语言基础、Swift语言基础、CocoaTouch、XcodeInterfaceBuilder界面开发、使用Xcode编写MVC程序、文本框和文本视图、按钮和标签、滑块、步进和图像、使用开关控件和分段控件、Web视图控件和可滚动视图控件、提醒和...

    一步一步学习 iOS 6 编程(第四版)

    第二部分:iOS 编程基础:Hello World 应用程序如何工作的? 第三部分:iOS 编程向导:创建一个简单的表视图(Table View)应 用程序 第四部分:定制 UITableView 表视图单元格 第五部分:如何处理 UITableView 中的行选择 ...

    iOS开发之如何跳到系统设置里的各种设置界面

    从应用跳到系统设置里的WiFi界面有这个需求存在吗?答案是肯定的。比如以下两个例子: 在没有网的状态下,你可能想提醒用户去设置界面连接WiFi。如果不能跳到WiFi界面,只能在APP里面做出文字提示。这样很多小白...

    iOS 9开发指南 2015年版)(2-1)

    全书共39章,循序渐进地讲解了iOS 9应用开发的基本知识。本书从搭建开发环境讲起,依次讲解了Objective-C语言基础,Swift语言基础,Cocoa Touch,Xcode Interface Builder界面开发,使用Xcode编写MVC程序,文本框和...

    一步步学IOS5编程完整版

    第二部分:iOS编程基础:Hello World应用程序如何工作的? 第三部分:iOS 编程向导:创建一个简单的表视图(Table View)应用程序 第四部分:定制UITableView表视图单元格 第五部分:如何处理UITableView中的行选择 ...

    IOS应用内跳转系统设置相关界面的方法

    在iOS开发中,有时会有跳转系统设置界面的需求,例如提示用户打开蓝牙或者WIFI,提醒用户打开推送或者位置权限等,接下来通过本文给大家介绍IOS应用内跳转系统设置相关界面的方法,喜欢的朋友参考下

    iOS 农历(阴历)与公历(阳历 )互转

    实现 类似与iOS的UIDatePicker的UIpickerView 农历选择器 ,可以进行生日提醒得相应的应用

    iOS 6 实践指南

    第一章、开始 iOS 开发 第二章、创建一个 iOS 应用 第三章、通过教你制作一个上架应用 PicDecor 来教你使用 view controllers 以及创建展示图 片 第四章、通过教你制作一个上架应用 Dial4 来学习访问地址簿/联系人列...

    iOS增、删、改、查系统提醒事件和日历事件.zip

    软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、...

    Reminder-Application:IOS提醒应用程序的组存储库

    提醒应用 目录 概述 描述 计划应用程序,可以激发具有相似目标和兴趣的人们一起联系,学习和进步。 建立一个社区,人们可以互相鼓励,为实现这些目标/利益采取行动。 应用评估 类别:生产力/社交网络 移动设备:此...

Global site tag (gtag.js) - Google Analytics