When does MFMessageComposeViewController.canSendSubject() return false?

422 Views Asked by At

I am using the iOS MessageUI framework to present a Message View Controller using MFMessageComposeViewController. I do not understand the return value from canSendSubject(). Apple docs say:

canSendSubject()

Indicates whether or not messages can include subject lines, according to the user’s configuration in Settings.

In my testing, canSendSubject() always returns true despite various combinations of switches in Settings: Messages. I expected the Show Subject Field switch setting would influence the return value, but it doesn't.

Does anyone know under what condition canSendSubject() will return false?

func displayMessagingUI() {
    
    let composeVC = MFMessageComposeViewController()
    composeVC.messageComposeDelegate = self
    composeVC.recipients = [String(8005551212)]
    composeVC.body = "This is a test message."
    
    if MFMessageComposeViewController.canSendSubject() {
        composeVC.subject = "Subject"
    }
    
    self.present(composeVC, animated: true, completion: nil)
}

Screenshot

Testing on iOS 11.1, iPhone X

1

There are 1 best solutions below

4
Yatendra On

canSendSubject()

Indicates whether or not messages can include subject lines, according to the user’s configuration in Settings.

and these settings you can enable or disable.If setting is disable it will return false.

for more info you can visit this link.