첨단 기술: 문자 & 메일 & 전화 & 인증 코드 & 프로그램 이동 & 정적 라이브러리 & 알림 & 출시

15544 단어
실제 테스트 녹화 화면 OSX QuickTime Player -> 파일 -> 화면 녹화
*iOS 9.0 오픈 무료 리얼리티 테스트*
OS X-code  :
1. AppID:  iCloud
2.   
3.   AppID Xcode
4.      mac 
5. Target - General - Team(Fix Issue)
6. Target - Build Settings -   (code signing ->Debug   )
7.     
8.     

  :
   -    -     (    )


1. 문자
Module 1 기능 부족->
- (IBAction)sendMessage:(UIButton *)sender {
  NSURL *url = [NSURL URLWithString:@"sms://xxx xxxx xxxx"];
  [[UIApplication sharedApplication]openURL:url];
}

Method 2기능 멀티->
      #import 
      

->클릭하여 트리거:
- (IBAction)sendMessage:(UIButton *)sender {
    [self showMessageView:@[@"xxx xxxx xxxx"] title:@"msg title" body:@"     "];
   
}

-> 호출 방법
-(void)showMessageView:(NSArray *)phones title:(NSString *)title body:(NSString *)body{
    if ([MFMessageComposeViewController canSendText]) {
        MFMessageComposeViewController *msgController = [MFMessageComposeViewController new];
        //           
        msgController.recipients = phones;
        msgController.body = body;
        msgController.title = title;
        //    *********  
        msgController.messageComposeDelegate = self;
        msgController.navigationBar.tintColor = [UIColor redColor];
        [self presentViewController:msgController animated:YES completion:nil];
    }else{
        NSLog(@"        ");
    }
}

-> 구현 프로토콜* #pragmark - MFMessage ComposeViewControllerDelegate*
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
    switch (result) {
        case MessageComposeResultSent:
            NSLog(@"    ");
            break;
        case MessageComposeResultFailed:
            NSLog(@"    ");
        case MessageComposeResultCancelled:
            NSLog(@"    ");
        default:
            break;
    }
}

2. 우편물
거의 문자랑 똑같아요. icloud에서 메일을 열고 계정을 설정해야 돼요.
      #import 
      

->클릭하여 트리거
**    *
- (IBAction)sendMail:(UIButton *)sender {
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *mailCon = [MFMailComposeViewController new];
        [mailCon setSubject:@"    "];
        [mailCon setToRecipients:@[@"[email protected]"]];
        
        /**   */
        // [mailCon setCcRecipients: *)#>];
        /**   */
        // [mailCon setBccRecipients: *)#>];
        
        [mailCon setMessageBody:@"           :          " isHTML:YES];/* ----> no      */
        /**   */
        UIImage *image = [UIImage imageNamed:@"pic"];
        NSData *imageData = UIImagePNGRepresentation(image);
        [mailCon addAttachmentData:imageData mimeType:@"image/png" fileName:@"abc.png"];
        
        //    
        mailCon.mailComposeDelegate = self;
               
        [self presentViewController:mailCon animated:YES completion:nil];
    }else{
        NSLog(@"     ");
    }
}

-> 구현 프로토콜 *# pragmark - MFmail ComposeViewControllerDelegate*

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
    switch (result) {
        case MessageComposeResultSent:
            NSLog(@"    ");
            break;
        case MessageComposeResultFailed:
            NSLog(@"    ");
        case MessageComposeResultCancelled:
            NSLog(@"    ");
        default:
            break;
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}

전화를 걸다
방식 1: 직접 지출
 NSURL *url = [NSURL URLWithString:@"tel://xxx xxxx xxxx"];
 [[UIApplication sharedApplication]openURL:url];

방식2: 사용자에게 블랙 애플 장치에 사용할 수 있는 선택을 주지만 이러한 방식의 접속은 거절당할 수 있다
 NSURL *url = [NSURL URLWithString:@"telprompt://xxx xxxx xxxx"];
 [[UIApplication sharedApplication]openURL:url];

방식 3: 선택의 기회가 있다
@interface ViewController ()
{
    UIWebView *_webView;
}

@implementation ViewController
 if (_webView == nil) {
        _webView = [[UIWebView alloc]initWithFrame:CGRectZero];
    } 
    NSURL *url = [NSURL URLWithString:@"tel://xxx xxxx xxxx"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];     
 [_webView loadRequest:request];

4. 문자 인증번호@사이트 주소
  • 1 mob.com 등록 계정, 활성화
  • 2 로그인 계정 마우스 오른쪽 상단에 놓인 이미지 -> 백스테이지 입장
  • 3 대응하는 모듈을 찾아서 appkey와 appsecret
  • 가져오기
  • 4 공식 문서에 따라 문자 검증
  • #import "AppDelegate.h"
    #import 
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [SMSSDK registerApp:MOBAPPKEY withSecret:MOBAPPSECRECT];
        return YES;
    }
    
     #import "ViewController.h"
     #import 
     
    **     **
    - (IBAction)getMsgCode:(UIButton *)sender {
        [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:@"xxxxxx" zone:@"86" customIdentifier:nil result:^(NSError *error) {
            if (error) {
                NSLog(@"       ,%@",error);
            }else{
                NSLog(@"       ");
            }
        }];
    }
    
    **  **
    - (IBAction)validMsgCode:(UIButton *)sender {
        [SMSSDK commitVerificationCode:self.msgCodeField.text phoneNumber:@"xxxxxx" zone:@"86" result:^(NSError *error) {
            if (error) {
                NSLog(@"    ");
            }else
            {
                NSLog(@"    ");
            }
        }];
    }
    

    5. 어플리케이션 간 점프
  • 1 하나의 프로그램을 만들면 MyApp이고 다른 프로그램을 만들면 YourApp
  • 이다.
  • 2 YourApp에 Target -> Info-> URL Types -> 증가 ->URLSchemesYourApp)
  • 3 My APP 설정 화이트리스트(IOS9 이후 요구사항) 타겟-> Info-> LSApplicationQueriesSchemes(Array)-> 증가YourApp
  • NSURL *url = [NSURL URLWithString:@"YourApp://"];
       UIApplication *app = [UIApplication sharedApplication];
       if ([app canOpenURL:url]) {
           [app openURL:url];
       }else{
           NSLog(@"        ");
       }
    

    다른 응용 프로그램으로 이동합니다. 예를 들어 웨이보, 위챗 등...해당하는 scheme와 설정 화이트 리스트를 찾습니다
    NSURL *url = [NSURL URLWithString:@"sinaweibo://"];
        UIApplication *app = [UIApplication sharedApplication];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }else{
            NSLog(@"       ");
        }
    

    진급: 차단 파라미터 -> MyApp에서 YourApp 2단계 페이지로 이동 - Page2
  • MyApp 구성
  • - (IBAction)gotoYourApp:(UIButton *)sender {
        NSURL *url = [NSURL URLWithString:@"YourApp://aaa?backScheme=MyApp"];
        UIApplication *app = [UIApplication sharedApplication];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }else{
            NSLog(@"        ");
        }
    }
    
    - (IBAction)gotoYourAppP2:(UIButton *)sender {
        NSURL *url = [NSURL URLWithString:@"YourApp://bbb?backScheme=MyApp"];
        UIApplication *app = [UIApplication sharedApplication];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }else{
            NSLog(@"      P2  ");
        }
    }
    
  • YourApp 구성
  •  #import Appdelegate
    
    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
        ***  
        NSLog(@"%@",url.absoluteString);
    
        ***      
        UINavigationController *navi = (UINavigationController *)self.window.rootViewController;
        ViewController *mainVc = (ViewController *)navi.topViewController;
        NSString *urlString = url.absoluteString;
        NSRange range = [urlString rangeOfString:@"backScheme="];
        
        if (range.length > 0) {
            NSInteger fromInteger = range.location + range.length;
            NSString *backStr = [urlString substringFromIndex:fromInteger];
            mainVc.backScheme = backStr;
            NSLog(@"backStr:%@",backStr);/*****    :`MyApp`
        }
        
        ***     P2
        if ([urlString hasPrefix:@"YourApp://bbb"]) {
            [mainVc performSegueWithIdentifier:@"page2Segie" sender:nil];
        }
        return YES;
    }
    
    ```
    ```
    #import "ViewController.h"
    - (IBAction)gotoMyApp:(UIButton *)sender {
    //    NSURL *url = [NSURL URLWithString:@"MyApp://"];
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://",self.backScheme]];
        UIApplication *app = [UIApplication sharedApplication];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }else{
            NSLog(@"        ");
        }
    }
    ```
    
    >   APP       
    
    **   :    **
    
    ```
    -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
    ```
    
    **   :ios9        (    IOS    )**
    
    ```
    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
        NSLog(@"%@",url.absoluteString);
        return YES;
    }
    ```
    
    **   :ios9    **
    
    ```
    -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options{
        
    }
    ```
    
    # 6.    
    >  :               ,      ,                           .            ,             
    
    - 1        ?
    ```
        framework(            ) - (     :Target -> BuildPhases ->CopyFiles)
    ```
    - 2        
        1.          2.          
    
            
     ```
    lipo -create/  /Debug-iphoneos/libStaticLibrary.a /  /Debug-iphonesimulator/libStaticLibrary.a -output/    /libStaticLibraryFile.a
    ```
         ,      。 .h      .a         。
    
    # 7.   
    >  :         ,                 ,                 。         。             。
    
        :APP    (  or  )     APP    (    or    )
    
    #####         
    - 1      
    - 2      (`                `)
    - 3     
    - 4     
    - 5     (        )
    
    #####  
    -  APP   ,         
    -  APP  ,     .         
    -  APP       ,             
    -       ,            APP
    
    ##1.     
      >  :        ,        ,         。              ,             。  :    、      、      
    
    `  `:iOS8.0           
    ```
              :[UIDevice currentDevice].systemVersion.floatValue
    ```
    
    **        :**
    
    1.         UILocalNotification
    ```
    #import "AppDelegate.h"
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge categories:nil];
            [[UIApplication sharedApplication]registerUserNotificationSettings:settings];
    ```
    2.       (                  )
    3.         userInfo(`   `)
    4.     (scheduleLocalNotification     or     )
    
    _        :_
    
    ```
          @property(nullable, nonatomic,copy) NSDate *fireDate;  
          @property(nullable, nonatomic,copy) NSString *alertBody;
          @property(nullable, nonatomic,copy) NSString *alertTitle;
          @property(nullable, nonatomic,copy) NSString *soundName;
          @property(nullable, nonatomic,assign) NSInteger applicationIconBadgeNumber;
           @property(nullable, nonatomic,copy) NSString *alertAction;
          @property(nullable, nonatomic,assign) NSCalendarUnit  *repeatCanlendar;
             @property(nullable, nonatomic,copy) NSString *alertLaunchImage;
           @property(nullable, nonatomic,copy) NSDictionary *userInfo;  ->userInfo[@"username"] = @"xxx"  -> localNoti.userInfo = userInfo;;
    ```
    
    ###       
    ##### App         (       ),      
    
    ```
    #import "AppDelegate.h"
    -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
        **  APP      **
        if (application.applicationState == UIApplicationStateActive) {
            NSLog(@"    ");
        }else{
            NSLog(@"    ");
            NSLog(@"       ");
            NSLog(@"%@",notification.userInfo[@"username"]);
        }
    }
    ```
    #####App    ,      
    **                         **
    - launchOptions               
         ->  key:UIApplicationLaunchOptionsLocalNoticifationKey      
    - launchOptions              
    
    ```
    #import "AppDelegate.h"
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        if (launchOptions) {
            label.text = [NSString stringWithFormat:@"      :%@",launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]];
         }else
             {
      label.text = @"          ";
             }
    }
    ```
    
    **    **
    
    ```
           [[UIApplication sharedApplication]cancelLocalNotification:];
           [[UIApplication sharedApplication]cancelAllLocalNotifications];
    ```
    
    ##2.     
    >              ,      ,   Apple     Apple         。
          :    、    、    iphone、     
    
    1. APNS(Apple Push Notification Service)  
     - 1  -App  IOS        ,iOS       APNS   
     - 2  -APNS   device_token (    +App  ),    App
     - 3  -App  device_token      PUSH     
     - 4  -                 ,      APNS
     - 5  -APNS    PUSH              App
    
    2.     [Apple     ](https://developer.apple.com)
             CSR(Certificate Signing Request)  
             :  CSR  : LaunchPad -    -     -      -      -            
      @[1](http://www.jianshu.com/p/585291fd9226) @[2](http://www.jianshu.com/p/e59bca4a1ac3)
            :
     - 1.       ,        
     - 2.                   ,           ,    。Certificate->All->Developer -> iOS App revoke
     - 3.     CSR  ->     (1)
     `  :  OSX WWDR         ,    ,   Apple            ` 
     - 4.    AppIDs    , Apple              (    id)
      :Identifiers->AppIDs->"+"->  App  ->  BundleID->      (Push Notifications)(2)
     - 5.   App ID ,  AppID          Certificate -> Development  -> "+" ->   "Apple Push Notification Server" SSL ->             App ID -> CSR        
     - 6.      
     - 7.      :Device ( X-code  windon       ID)->     +  ID     
    
    ##3.[    ](https://www.jpush.cn)
     - 1     
     - 2   APPKEY APPSECRET   Apple       `(    &    )`,        ".p12"     
     - 3     sdk       lib           PushConfig.plish        APPDelegate.h 
      - 3.1   SDK    ,     lib    (  APService.h、libPushSDK.a)          )
      - 3.2     
    ```
    CFNetwork.framework
    CoreFoundation.framework
    CoreTelephony.framework
    SystemConfiguration.framework
    CoreGraphics.framework 
    Foundation.framework
    UIKit.framework
    Security.framework
    libz.dylib
    ```
    
      - 3.3      PushConfig.plist  
                      PropertyList  ,      PushConfig.plist,  Portal        APP_KEY   
    
        ```
        "APS_FOR_PRODUCTION = "0"; 
        "CHANNEL" = "Publish channel";
        "APP_KEY" = "AppKey copied from JPush Portal application";
        ```
      - 3.4     
    
    ##8.     
      - 1 [      ](https://developer.apple.com)    App id(  id)
      - 2   bundleid    id  
      - 3    [iTunes Connect](https://itunesconnect.apple.com) ->  APP ->   APP  (  Appid)
      - 4     :         ->Product ->Archive
      - 5    [iTunes Connect](https://itunesconnect.apple.com)       
    
          :
    1.        ,     2.            3.     4.      UI/UE (    ) 5.      
    
            :
        1.   UI  2.           3.         4.      5.         6.          7.       

    좋은 웹페이지 즐겨찾기