Pre*_*van 4 app-store apple-push-notifications ios
是否有任何文档说当Appstore上的应用程序更新时,Appstore本身会向用户发送有关更新的推送通知?
您可以使用Search 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.
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用了JSONKit ..您可以使用任何您喜欢的库来解析Apple检索到的JSON.
注意:您可以使用此选项通知用户打开应用程序时有更新.如果您希望在更新生效后立即通知用户,则需要推送通知.
希望这可以帮助.
干杯!
| 归档时间: |
|
| 查看次数: |
2372 次 |
| 最近记录: |