如何规避苹果审查,实现app store上的app版本强制更新
发布日期:2021-11-10 08:20:48
浏览次数:1
分类:技术文章
本文共 4431 字,大约阅读时间需要 14 分钟。
要想规避苹果审查,我们需要通过调用数据接口来控制调用app 版本强制更新功能:当苹果在审查的时候,我们可以通过后台数据控制关闭版本强制更新功能,等苹果审核通过以后我通过后台控制打开版本强制更新功能。下面是app 版本强制更新功能实现的代码:
AppDelegate.h文件
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UIAlertViewDelegate> @property (strong, nonatomic) UIWindow *window; @endAppDelegate.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:. } @endViewController.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController -(void)checkVersion; @endViewController.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转载地址:https://blog.csdn.net/cxiao_11/article/details/52371378 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年04月03日 05时52分31秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
阿里云上的docker安装
2019-04-27
WordPress Kyma插件里Connect和disconnect按钮的动态显示逻辑
2019-04-27
SAP CRM One Order CLOSING date change debug
2019-04-27
How to determine if SAP CRM UI is extensible
2019-04-27
CRM_ORDER_PR_ASSIGN_SELECT_CB
2019-04-27
SAP CRM One Order old design in index table
2019-04-27
SAP GraphQL console UI的实现原理
2019-04-27
SAP CRM的user status和system status
2019-04-27
生成SAP Leonardo API Access Token的python代码
2019-04-27
如何判断一个SAP CRM UI能否被扩展
2019-04-27
如何判断一个SAP CRM UI能否被扩展
2019-04-27