当前位置:小鱼儿玄机二站 > 编程应用 > 短信分享

短信分享

文章作者:编程应用 上传时间:2019-09-11

效用:用于短信分享内容

 //MARK: 短信 // 调用方法 func sendMessage() { if (self.canSendText { self.presentViewController(self.configuredMessageComposeViewController(), animated: true, completion: nil) } else { MPAlertView.showAlertView("当前设备不支持短信功能") } } // 是否能发送短信 func canSendText() -> Bool { return MFMessageComposeViewController.canSendText() } func configuredMessageComposeViewController() -> MFMessageComposeViewController { let messageComposeVC = MFMessageComposeViewController() messageComposeVC.messageComposeDelegate = self // 设置代理,遵循代理方法 let inviteCode = NSUserDefaults.standardUserDefaults().stringForKey(kInviteCode) messageComposeVC.body = "短信内容" return messageComposeVC } //MARK: MFMessageComposeViewControllerDelegate func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) { switch result.value { case 0: MPAlertView.showAlertView self.dismissViewControllerAnimated(true, completion: nil) case 1: MPAlertView.showAlertView self.dismissViewControllerAnimated(true, completion: nil) case 2: MPAlertView.showAlertView self.dismissViewControllerAnimated(true, completion: nil) default: controller.dismissViewControllerAnimated(true, completion: nil) } self.dismissViewControllerAnimated(true, completion: nil) }

本文由小鱼儿玄机二站发布于编程应用,转载请注明出处:短信分享

关键词: