Send text messages that refer to content

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.