Search code examples
iosswiftmfmessagecomposeviewcontroller

Value of type 'MFMessageComposeViewController' has no member 'setUPIVerificationCodeSendCompletion'


I am trying to use setUPIVerificationCodeSendCompletion, a new instance method of MFMessageComposeViewController.

While trying to use it I am getting this error:
Value of type 'MFMessageComposeViewController' has no member 'setUPIVerificationCodeSendCompletion'.

The required entitlement(com.apple.developer.upi-device-validation) is also added to the app.

import MessageUI

class SendSms {
    
    func createMessageController() -> UIViewController {
        let vc = MFMessageComposeViewController()
        vc.setUPIVerificationCodeSendCompletion { result in
            print("\(result)")
        }
        return vc
    }
}

Solution

  • As we observe the function setUPIVerificationCodeSendCompletion: written in Objective C language in MFMessageComposeViewController(UPI) category class and your code is written in swift language.

    So access these method in swift class, you have to import #import <MessageUI/MFMessageComposeViewController+UPI.h> in your project bridge header.