ios 类型“MFMessageComposeViewController”的值没有成员“setUPIVerificationCodeSendCompletion”

ergxz8rk  于 12个月前  发布在  iOS
关注(0)|答案(1)|浏览(120)

我尝试使用setUPIVerificationCodeSendCompletion,MFMessageComposeViewController的一个新示例方法。
当我尝试使用它时,我得到了这个错误:
类型“MFMessageComposeViewController”的值没有成员“setUPIVerificationCodeSendCompletion”。
所需的授权(com.apple.developer.upi-device-validation)也会添加到应用程序中。

import MessageUI

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

falq053o1#

正如我们在MFMessageComposeViewController(UPI)类别类中观察到用Objective C语言编写的函数setUPIVerificationCodeSendCompletion:,而您的代码是用swift语言编写的。
所以在swift类中访问这些方法,你必须在你的项目桥头中导入#import <MessageUI/MFMessageComposeViewController+UPI.h>

相关问题