@ -47,6 +47,10 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					        } 
        } 
 
			
		
	
		
		
			
				
					
					    } 
    } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    deinit  { 
 
			
		
	
		
		
			
				
					
					        Logger . verbose ( " [InviteFlow] deinit " ) 
 
			
		
	
		
		
			
				
					
					    } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    //   MARK:   T w i t t e r 
    //   MARK:   T w i t t e r 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    func  canTweet ( )  ->  Bool  { 
    func  canTweet ( )  ->  Bool  { 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -88,17 +92,16 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					    func  contactsPicker ( _ :  ContactsPicker ,  didSelectMultipleContacts  contacts :  [ Contact ] )  { 
    func  contactsPicker ( _ :  ContactsPicker ,  didSelectMultipleContacts  contacts :  [ Contact ] )  { 
 
			
		
	
		
		
			
				
					
					        Logger . debug ( " \( TAG )  didSelectContacts: \( contacts ) " ) 
        Logger . debug ( " \( TAG )  didSelectContacts: \( contacts ) " ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        self . presentingViewController . dismiss ( animated :  true ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        guard  let  inviteChannel  =  channel  else  { 
        guard  let  inviteChannel  =  channel  else  { 
 
			
		
	
		
		
			
				
					
					            Logger . error ( " \( TAG )  unexpected nil channel after returning from contact picker. " ) 
            Logger . error ( " \( TAG )  unexpected nil channel after returning from contact picker. " ) 
 
			
		
	
		
		
			
				
					
					            self . presentingViewController . dismiss ( animated :  true ) 
 
			
		
	
		
		
			
				
					
					            return 
            return 
 
			
		
	
		
		
			
				
					
					        } 
        } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        switch  inviteChannel  { 
        switch  inviteChannel  { 
 
			
		
	
		
		
			
				
					
					        case  . message : 
        case  . message : 
 
			
		
	
		
		
			
				
					
					            let  phoneNumbers :  [ String ]  =  contacts . map  {  $0 . userTextPhoneNumbers . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
            let  phoneNumbers :  [ String ]  =  contacts . map  {  $0 . userTextPhoneNumbers . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
 
			
		
	
		
		
			
				
					
					            di smissAndS endSMSTo( phoneNumbers :  phoneNumbers ) 
            ( phoneNumbers :  phoneNumbers ) 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					        case  . mail : 
        case  . mail : 
 
			
		
	
		
		
			
				
					
					            let  recipients :  [ String ]  =  contacts . map  {  $0 . emails . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
            let  recipients :  [ String ]  =  contacts . map  {  $0 . emails . first  } . filter  {  $0  !=  nil  } . map  {  $0 !  } 
 
			
		
	
		
		
			
				
					
					            sendMailTo ( emails :  recipients ) 
            sendMailTo ( emails :  recipients ) 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -126,7 +129,9 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    func  contactsPicker ( _ :  ContactsPicker ,  contactFetchDidFail  error :  NSError )  { 
    func  contactsPicker ( _ :  ContactsPicker ,  contactFetchDidFail  error :  NSError )  { 
 
			
		
	
		
		
			
				
					
					        Logger . error ( " \( self . logTag )  in  \( #function )  with error:  \( error ) " ) 
        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 )  { 
    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 ] )  { 
    public  func  sendSMSTo ( phoneNumbers :  [ String ] )  { 
 
			
		
	
		
		
			
				
					
					        if  #available ( iOS  10.0 ,  * )  { 
        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 . 
            //   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 " ) 
        let  inviteText  =  NSLocalizedString ( " SMS_INVITE_BODY " ,  comment :  " body sent to contacts when inviting to Install Signal " ) 
 
			
		
	
		
		
			
				
					
					        messageComposeViewController . body  =  inviteText . appending ( "   \( self . installUrl ) " ) 
        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 
    //   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,8 +189,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					    func  messageComposeViewController ( _  controller :  MFMessageComposeViewController ,  didFinishWith  result :  MessageComposeResult )  { 
    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 . 
        //   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 ( ) 
        UIUtil . applySignalAppearence ( ) 
 
			
		
	
		
		
			
				
					
					        self . presentingViewController . dismiss ( animated :  true ,  completion :  nil ) 
        self . presentingViewController . dismiss ( animated :  true )  { 
 
			
				
				
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
	
		
		
			
				
					
					            switch  result  { 
            switch  result  { 
 
			
		
	
		
		
			
				
					
					            case  . failed : 
            case  . failed : 
 
			
		
	
		
		
			
				
					
					                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -201,6 +201,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					                Logger . debug ( " \( self . TAG )  user cancelled message invite " ) 
                Logger . debug ( " \( self . TAG )  user cancelled message invite " ) 
 
			
		
	
		
		
			
				
					
					            } 
            } 
 
			
		
	
		
		
			
				
					
					        } 
        } 
 
			
		
	
		
		
			
				
					
					    } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    //   MARK:   M a i l 
    //   MARK:   M a i l 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -226,7 +227,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					    func  sendMailTo ( emails  recipientEmails :  [ String ] )  { 
    func  sendMailTo ( emails  recipientEmails :  [ String ] )  { 
 
			
		
	
		
		
			
				
					
					        let  mailComposeViewController  =  MFMailComposeViewController ( ) 
        let  mailComposeViewController  =  MFMailComposeViewController ( ) 
 
			
		
	
		
		
			
				
					
					        mailComposeViewController . mailComposeDelegate  =  self 
        mailComposeViewController . mailComposeDelegate  =  self 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        mailComposeViewController . setBccRecipients ( recipientEmails ) 
        mailComposeViewController . setBccRecipients ( recipientEmails ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        let  subject  =  NSLocalizedString ( " EMAIL_INVITE_SUBJECT " ,  comment :  " subject of email sent to contacts when inviting to install Signal " ) 
        let  subject  =  NSLocalizedString ( " EMAIL_INVITE_SUBJECT " ,  comment :  " subject of email sent to contacts when inviting to install Signal " ) 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -236,17 +236,14 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					        mailComposeViewController . setMessageBody ( body ,  isHTML :  false ) 
        mailComposeViewController . setMessageBody ( body ,  isHTML :  false ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        self . presentingViewController . dismiss ( animated :  true )  { 
        self . presentingViewController . dismiss ( animated :  true )  { 
 
			
		
	
		
		
			
				
					
					            self . presentingViewController . navigationController ? . present ( mailComposeViewController ,  animated :  true )  { 
            self . presentingViewController . present ( mailComposeViewController ,  animated :  true ) 
 
			
				
				
			
		
	
		
		
			
				
					
					                UIUtil . applySignalAppearence ( ) 
 
			
		
	
		
		
			
				
					
					            } 
 
			
		
	
		
		
	
		
		
			
				
					
					        } 
        } 
 
			
		
	
		
		
			
				
					
					    } 
    } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    //   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 
    //   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 ? )  { 
    func  mailComposeController ( _  controller :  MFMailComposeViewController ,  didFinishWith  result :  MFMailComposeResult ,  error :  Error ? )  { 
 
			
		
	
		
		
			
				
					
					        self . presentingViewController . dismiss ( animated :  true ,  completion :  nil ) 
        self . presentingViewController . dismiss ( animated :  true )  { 
 
			
				
				
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
	
		
		
			
				
					
					            switch  result  { 
            switch  result  { 
 
			
		
	
		
		
			
				
					
					            case  . failed : 
            case  . failed : 
 
			
		
	
		
		
			
				
					
					                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
                let  warning  =  UIAlertController ( title :  nil ,  message :  NSLocalizedString ( " SEND_INVITE_FAILURE " ,  comment :  " Alert body after invite failed " ) ,  preferredStyle :  . alert ) 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -260,5 +257,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
 
			
		
	
		
		
			
				
					
					                Logger . debug ( " \( self . TAG )  user cancelled mail invite. " ) 
                Logger . debug ( " \( self . TAG )  user cancelled mail invite. " ) 
 
			
		
	
		
		
			
				
					
					            } 
            } 
 
			
		
	
		
		
			
				
					
					        } 
        } 
 
			
		
	
		
		
			
				
					
					    } 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					} }