@ -47,6 +47,10 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    deinit  { 
 
		
	
		
			
				        Logger . verbose ( " [InviteFlow] deinit " ) 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    //   MARK:   T w i t t e r 
 
		
	
		
			
				
 
		
	
		
			
				    func  canTweet ( )  ->  Bool  { 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -88,17 +92,16 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				    func  contactsPicker ( _ :  ContactsPicker ,  didSelectMultipleContacts  contacts :  [ Contact ] )  { 
 
		
	
		
			
				        Logger . debug ( " \( TAG )  didSelectContacts: \( contacts ) " ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true ) 
 
		
	
		
			
				
 
		
	
		
			
				        guard  let  inviteChannel  =  channel  else  { 
 
		
	
		
			
				            Logger . error ( " \( TAG )  unexpected nil channel after returning from contact picker. " ) 
 
		
	
		
			
				            self . presentingViewController . dismiss ( animated :  true ) 
 
		
	
		
			
				            return 
 
		
	
		
			
				        } 
 
		
	
		
			
				
 
		
	
		
			
				        switch  inviteChannel  { 
 
		
	
		
			
				        case  . message : 
 
		
	
		
			
				            let  phoneNumbers :  [ String ]  =  contacts . map  {  $0 . userTextPhoneNumbers . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
 
		
	
		
			
				            di smissAndS endSMSTo( phoneNumbers :  phoneNumbers ) 
 
		
	
		
			
				            ( phoneNumbers :  phoneNumbers ) 
 
		
	
		
			
				        case  . mail : 
 
		
	
		
			
				            let  recipients :  [ String ]  =  contacts . map  {  $0 . emails . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
 
		
	
		
			
				            sendMailTo ( emails :  recipients ) 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -126,7 +129,9 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				
 
		
	
		
			
				    func  contactsPicker ( _ :  ContactsPicker ,  contactFetchDidFail  error :  NSError )  { 
 
		
	
		
			
				        Logger . error ( " \( self . logTag )  in  \( #function )  with error:  \( error ) " ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true )  { 
 
		
	
		
			
				            OWSAlerts . showErrorAlert ( message :  NSLocalizedString ( " ERROR_COULD_NOT_FETCH_CONTACTS " ,  comment :  " Error indicating that the phone's contacts could not be retrieved. " ) ) 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    func  contactsPickerDidCancel ( _ :  ContactsPicker )  { 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -159,12 +164,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    public  func  dismissAndSendSMSTo ( phoneNumbers :  [ String ] )  { 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true )  { 
 
		
	
		
			
				            self . sendSMSTo ( phoneNumbers :  phoneNumbers ) 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    public  func  sendSMSTo ( phoneNumbers :  [ String ] )  { 
 
		
	
		
			
				        if  #available ( iOS  10.0 ,  * )  { 
 
		
	
		
			
				            //   i O S 1 0   m e s s a g e   c o m p o s e   v i e w   d o e s n ' t   r e s p e c t   s o m e   s y s t e m   a p p e a r e n c e   a t t r i b u t e s . 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -180,7 +179,9 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				
 
		
	
		
			
				        let  inviteText  =  NSLocalizedString ( " SMS_INVITE_BODY " ,  comment :  " body sent to contacts when inviting to Install Signal " ) 
 
		
	
		
			
				        messageComposeViewController . body  =  inviteText . appending ( "   \( self . installUrl ) " ) 
 
		
	
		
			
				        self . presentingViewController . navigationController ? . present ( messageComposeViewController ,  animated :  true ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true )  { 
 
		
	
		
			
				            self . presentingViewController . present ( messageComposeViewController ,  animated :  true ) 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    //   MARK:   M e s s a g e C o m p o s e V i e w C o n t r o l l e r D e l e g a t e 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -188,17 +189,17 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				    func  messageComposeViewController ( _  controller :  MFMessageComposeViewController ,  didFinishWith  result :  MessageComposeResult )  { 
 
		
	
		
			
				        //   R e v e r t   s y s t e m   s t y l i n g   a p p l i e d   t o   m a k e   m e s s a g i n g   a p p   l e g i b l e   o n   i O S 1 0 . 
 
		
	
		
			
				        UIUtil . applySignalAppearence ( ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true , completion :  nil )  
 
		
	
		
			
				
  
		
	
		
			
				        switch  result  { 
 
		
	
		
			
				        case  . failed : 
 
		
	
		
			
				            let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
 
		
	
		
			
				            warning . addAction ( UIAlertAction ( title :  CommonStrings . dismissButton ,  style :  . default ,  handler :  nil ) ) 
 
		
	
		
			
				            self . presentingViewController . present ( warning ,  animated :  true ,  completion :  nil ) 
 
		
	
		
			
				        case  . sent : 
 
		
	
		
			
				            Logger . debug ( " \( self . TAG )  user successfully invited their friends via SMS. " ) 
 
		
	
		
			
				        case  . cancelled : 
 
		
	
		
			
				            Logger . debug ( " \( self . TAG )  user cancelled message invite " ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true ) {  
 
		
	
		
			
				            switch  result  {   
		
	
		
			
				            case  . failed :  
 
		
	
		
			
				                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert )  
 
		
	
		
			
				                warning . addAction ( UIAlertAction ( title :  CommonStrings . dismissButton ,  style :  . default ,  handler :  nil )  ) 
 
		
	
		
			
				                self . presentingViewController . present ( warning ,  animated :  true ,  completion :  nil  ) 
 
		
	
		
			
				            case  . sent : 
 
		
	
		
			
				                Logger . debug ( " \( self . TAG )  user successfully invited their friends via SMS. " )  
 
		
	
		
			
				            case  . cancelled : 
 
		
	
		
			
				                Logger . debug ( " \( self . TAG )  user cancelled message invite " )  
 
		
	
		
			
				            } 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -226,7 +227,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				    func  sendMailTo ( emails  recipientEmails :  [ String ] )  { 
 
		
	
		
			
				        let  mailComposeViewController  =  MFMailComposeViewController ( ) 
 
		
	
		
			
				        mailComposeViewController . mailComposeDelegate  =  self 
 
		
	
		
			
				
 
		
	
		
			
				        mailComposeViewController . setBccRecipients ( recipientEmails ) 
 
		
	
		
			
				
 
		
	
		
			
				        let  subject  =  NSLocalizedString ( " EMAIL_INVITE_SUBJECT " ,  comment :  " subject of email sent to contacts when inviting to install Signal " ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -236,28 +236,26 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
		
	
		
			
				        mailComposeViewController . setMessageBody ( body ,  isHTML :  false ) 
 
		
	
		
			
				
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true )  { 
 
		
	
		
			
				            self . presentingViewController . navigationController ? . present ( mailComposeViewController ,  animated :  true )  { 
 
		
	
		
			
				                UIUtil . applySignalAppearence ( ) 
 
		
	
		
			
				            } 
 
		
	
		
			
				            self . presentingViewController . present ( mailComposeViewController ,  animated :  true ) 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } 
 
		
	
		
			
				
 
		
	
		
			
				    //   MARK:   M a i l C o m p o s e V i e w C o n t r o l l e r D e l e g a t e 
 
		
	
		
			
				
 
		
	
		
			
				    func  mailComposeController ( _  controller :  MFMailComposeViewController ,  didFinishWith  result :  MFMailComposeResult ,  error :  Error ? )  { 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true , completion :  nil )  
 
		
	
		
			
				
  
		
	
		
			
				        switch  result  { 
 
		
	
		
			
				        case  . failed : 
 
		
	
		
			
				            let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
 
		
	
		
			
				            warning . addAction ( UIAlertAction ( title :  CommonStrings . dismissButton ,  style :  . default ,  handler :  nil ) ) 
 
		
	
		
			
				            self . presentingViewController . present ( warning ,  animated :  true ,  completion :  nil ) 
 
		
	
		
			
				        case  . sent : 
 
		
	
		
			
				            Logger . debug ( " \( self . TAG )  user successfully invited their friends via mail. " ) 
 
		
	
		
			
				        case  . saved : 
 
		
	
		
			
				            Logger . debug ( " \( self . TAG )  user saved mail invite. " ) 
 
		
	
		
			
				        case  . cancelled : 
 
		
	
		
			
				            Logger . debug ( " \( self . TAG )  user cancelled mail invite. " ) 
 
		
	
		
			
				        self . presentingViewController . dismiss ( animated :  true ) {  
 
		
	
		
			
				            switch  result  {   
		
	
		
			
				            case  . failed :  
 
		
	
		
			
				                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert )  
 
		
	
		
			
				                warning . addAction ( UIAlertAction ( title :  CommonStrings . dismissButton ,  style :  . default ,  handler :  nil )  ) 
 
		
	
		
			
				                self . presentingViewController . present ( warning ,  animated :  true ,  completion :  nil  ) 
 
		
	
		
			
				            case  . sent : 
 
		
	
		
			
				                Logger . debug ( " \( self . TAG )  user successfully invited their friends via mail. " )  
 
		
	
		
			
				            case  . saved : 
 
		
	
		
			
				                Logger . debug ( " \( self . TAG )  user saved mail invite. " )  
 
		
	
		
			
				            case  . cancelled : 
 
		
	
		
			
				                Logger . debug ( " \( self . TAG )  user cancelled mail invite. " )  
 
		
	
		
			
				            } 
 
		
	
		
			
				        } 
 
		
	
		
			
				    }