有没有文档说明当Appstore上的应用程序更新时,Appstore本身会向用户发送有关更新的推送通知?
你可以使用搜索API来实现这个功能。在你的应用程序中,在启动后,检查AppStore上你的应用程序的最新版本。像这样:
- (void) checkForUpdates
{
NSString *jsonUrl = @"http://itunes.apple.com/search?term=yourAppName&entity=software&limit=1";
NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:jsonUrl]];
JSONDecoder *jsonKitDecoder = [JSONDecoder decoderWithParseOptions:JKParseOptionNone];
NSObject *jsonObject = [jsonKitDecoder objectWithData:jsonData error:nil];
int results = [[jsonObject valueForKey:@"resultCount"] intValue];
if(results >0) // has results
{
NSArray *results = [jsonObject valueForKey:@"results"];
for(NSObject *aResult in results)
{
NSString *appStoreVersion = [aResult valueForKey:@"version"];
NSString *localVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
if(![appStoreVersion isEqualToString:localVersion])
{
//there is an update available. Go crazy.
}
}
}
}