你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 開發:應用內實現 更新提醒

iOS 開發:應用內實現 更新提醒

編輯: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"];  
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved