ATSテスター作ってみた(iOS9~iOS10)※2016/10/31追記
iOS10からATS対応が本格化するらしい。
要件としては↓を満たす事みたいだ。
①The server must support at least Transport Layer Security (TLS) protocol version 1.2.
②Connection ciphers are limited to those that provide forward secrecy (see the list of ciphers below.)
③Certificates must be signed using a SHA256 or greater signature hash algorithm, with either a 2048-bit or greater RSA key or a 256-bit or greater Elliptic-Curve (ECC) key.
で、ふとサーバが求められている要件を満たしているか簡易的にチェックできたらなーと思ったので、
超簡易ATSテスター作ってみた
<機能>
① アクセスするURLを入力出来る。
② フォアグラウンドアクセス(ブラウザ起動)とバックグラウンドアクセス(ブラウザ起動しない)を選べる
③ エラーが起これば、理由を表示(フォアグラウンドならブラウザ側でエラーを吐くはずなので実装しなかったが……後でやっとく)
<コード>
ViewController.h
// // ViewController.h // AppHttpRequester #import <UIKit/UIKit.h> #import <AdSupport/AdSupport.h> @interface ViewController : UIViewController<NSURLSessionDelegate> @end
ViewController.m
// // ViewController.m // AppHttpRequester #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UILabel *IdfaLabel; @property (weak, nonatomic) IBOutlet UITextField *UrlText; - (IBAction)ForeGroundRqBtn:(id)sender; - (IBAction)BackGroundRqBtn:(id)sender; @property (weak, nonatomic) IBOutlet UITextView *Result; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. ASIdentifierManager *idfa = [ASIdentifierManager sharedManager]; self.IdfaLabel.text = idfa.advertisingIdentifier.UUIDString; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } //Safariを起動してリクエスト送ります(指定したURLを開く) - (IBAction)ForeGroundRqBtn:(id)sender { NSString *urlStr = self.UrlText.text; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]]; [self.UrlText resignFirstResponder]; } - (IBAction)BackGroundRqBtn:(id)sender { NSString *urlStr = self.UrlText.text; NSURL *url = [NSURL URLWithString:urlStr]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; NSURLSessionConfiguration *conf = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:conf delegate:self delegateQueue:[NSOperationQueue mainQueue]]; NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data,NSURLResponse *response,NSError *error){ if(error){ self.Result.text = [NSString stringWithFormat:@"エラー:%@",error]; } }]; [task resume]; [self.UrlText resignFirstResponder]; } @end
出来上がったものがこちらで~す
※ついでにIDFAを出力しているのは興味があったから
NGだと↑みたいにエラーが返ってくる。
使い所がそこまであるのかは、微妙。
以上