@ -50,6 +50,10 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
}
deinit {
Logger . verbose ( " [InviteFlow] deinit " )
}
// MARK: T w i t t e r
func canTweet ( ) -> Bool {
@ -91,10 +95,9 @@ 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
}
@ -129,7 +132,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 ) {
@ -184,7 +189,7 @@ 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 . 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
@ -192,17 +197,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 " )
}
}
}
@ -230,7 +235,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 " )
@ -240,28 +244,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. " )
}
}
}