#import "ViewController.h"
#import <MessageUI/MessageUI.h>
@interface viewcontroller () <mfmessagecomposeviewcontrollerdelegate>
@end
@implementation Viewcontroller
-(void) Touchesbegan: (nsset<uitouch *> *) touches withevent: (uievent *) Event
{
if ([mfmessagecomposeviewcontroller cansendtext]) {
mfmessagecomposeviewcontroller *controller = [[mfmessagecomposeviewcontroller alloc] Init];
Controller. Recipients = [nsarray arraywithobject:@ "13888888888"]; Assign sender
Controller. Body = @ " Send SMS Verification "; specify what to send
Controller. messagecomposedelegate = self; set up proxy
[self presentviewcontroller: Controller animated:YES completion: ^{
// Modify SMS interface title
[[[Controller viewcontrollers]lastobject]navigationitem ]settitle:@ " Modify the SMS Interface "];
}];
}Else{
uialertcontroller * ALERTVC = [uialertcontroller alertcontrollerwithtitle :@ " warning " Message:@ " This device does not support sending " preferredstyle:uialertcontrollerstylealert];
uialertaction *action = [uialertaction actionwithtitle:@ "Acton" style: uialertactionstyledefault handler: ^ (uialertaction * _nonnull action) {
return ;
}];
[ALERTVC addaction: action];
[self presentviewcontroller: ALERTVC animated:YES completion:Nil ];
}
}
-(void) Messagecomposeviewcontroller: (mfmessagecomposeviewcontroller *) controller Didfinishwithresult: (messagecomposeresult) result
{
[Controller dismissviewcontrolleranimated:NO completion:nil];
switch (result) {
case messagecomposeresultcancelled:
{
//click Cancel Button
NSLog(@ " Cancel send ");
}
break;
case messagecomposeresultfailed://Send failed
{
NSLog(@ " send failed ");
}
break;
case messagecomposeresultsent:
{
//do something
NSLog(@ " sent out ");
}
break;
default:
break;
}
}
@end
Send text messages that refer to content