iOS 规避苹果审查,实现app store上的app版本强制更新
2017-11-25 09:07
567 查看
要想规避苹果审查,我们需要通过调用数据接口来控制调用app 版本强制更新功能:当苹果在审查的时候,我们可以通过后台数据控制关闭版本强制更新功能,等苹果审核通过以后我通过后台控制打开版本强制更新功能。下面是app 版本强制更新功能实现的代码:
AppDelegate.h文件
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UIAlertViewDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m文件
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
{
ViewController *vc;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
vc = [[ViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav;
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[vc checkVersion];
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
ViewController.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
-(void)checkVersion;
@end
ViewController.m文件
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"版本检测更新";
self.view.backgroundColor = [UIColor whiteColor];
[self checkVersion]; //检测升级
}
-(void)checkVersion
{
NSString *newVersion;
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/cn/lookup?id=1139094792"];//1137865162
NSString *jsonResponseString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
// NSLog(@"通过appStore获取的数据信息:%@",jsonResponseString);
NSData *data = [jsonResponseString dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSArray *array = json[@"results"];
for (NSDictionary *dic in array) {
newVersion = [dic valueForKey:@"version"];
}
// NSLog(@"通过appStore获取的版本号是:%@",newVersion);
// 解析json数据
//获取本地软件的版本号
NSString *localVersion = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *msg = [NSString stringWithFormat:@"你当前的版本是V%@,发现新版本V%@,请更新新版本哦!",localVersion,newVersion];
//对比发现的新版本和本地的版本
if ([newVersion floatValue] > [localVersion floatValue])
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"升级提示"message:msg preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
[alert addAction:[UIAlertAction actionWithTitle:@"现在升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/yi-ka-tongbic-ban/id1139094792?l=en&mt=8"]];//1137865162
// NSLog(@"点击现在升级按钮");
}]];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
AppDelegate.h文件
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UIAlertViewDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m文件
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
{
ViewController *vc;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
vc = [[ViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav;
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[vc checkVersion];
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
ViewController.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
-(void)checkVersion;
@end
ViewController.m文件
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"版本检测更新";
self.view.backgroundColor = [UIColor whiteColor];
[self checkVersion]; //检测升级
}
-(void)checkVersion
{
NSString *newVersion;
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/cn/lookup?id=1139094792"];//1137865162
NSString *jsonResponseString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
// NSLog(@"通过appStore获取的数据信息:%@",jsonResponseString);
NSData *data = [jsonResponseString dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSArray *array = json[@"results"];
for (NSDictionary *dic in array) {
newVersion = [dic valueForKey:@"version"];
}
// NSLog(@"通过appStore获取的版本号是:%@",newVersion);
// 解析json数据
//获取本地软件的版本号
NSString *localVersion = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *msg = [NSString stringWithFormat:@"你当前的版本是V%@,发现新版本V%@,请更新新版本哦!",localVersion,newVersion];
//对比发现的新版本和本地的版本
if ([newVersion floatValue] > [localVersion floatValue])
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"升级提示"message:msg preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
[alert addAction:[UIAlertAction actionWithTitle:@"现在升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/yi-ka-tongbic-ban/id1139094792?l=en&mt=8"]];//1137865162
// NSLog(@"点击现在升级按钮");
}]];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- 如何规避苹果审查,实现app store上的app版本强制更新
- iOS APP内弹窗推送版本更新信息(实现跳转、强制更新等)
- iOS APP版本更新跳转到App Store下载/更新方法
- iOS开发:2017 苹果APP上架更新应用版本注意事项及APP版本迭代步骤方法
- iOS开发007 苹果appStore检查版本更新与从app里引导跳到appstore评论页面
- 苹果app在安装过程中出现此应用需要开发者更新以在此ios版本上运行
- iOS APP如何实现版本检测更新
- iOS APP如何实现版本检测更新
- 苹果要求2015年2月起所有新app以及版本更新必须支持iOS 8 SDK和64-bit
- ios实现app强制更新功能
- 提交至APP STORE的APP和APP更新必须使用Xcode5.1.1(或更高级版本)及ios 7 sdk进行构建
- IOS 怎样实现APP版本更新
- 苹果要求所有新app以及版本更新必须支持iOS 8 SDK和64-bit
- 通过扫码自定义链接安装iOS app,版本更新总结。
- iOS热更新_无需发布新版本实现app更新
- iOS app版本迭代(iOS中app在iTunes中更新版本流程)
- cordova 混合开发中苹果iOS开发中直接跳转到App Store里面自己的app的方法
- ios 实现版本更新检查
- ios app版本更新流程及问题总结
- app版本更新的四种实现方式