Call/SMS sharing/email sharing

Source: Internet
Author: User

Created by Apple on 15/6/17.

Copyright (c) year Super All rights reserved.

//

#import "LCShareController.h"

#import <MessageUI/MessageUI.h> @interface Lcsharecontroller () <mfmessagecomposeviewcontrollerdelegate, Mfmailcomposeviewcontrollerdelegate> @property (nonatomic, strong) UIWebView *webview;
@end

@implementation Lcsharecontroller
-(void) dealloc{
NSLog (@ "Dealloc");
}


-(UIWebView *) webview{
if (_webview = = nil) {
_webview = [UIWebView new];

}
return _webview;
}



-(void) setdata{

__weak Lcsharecontroller *weakself = self;
__weak typeof (self) weakself = self;
Lcitem *item1 = [Lcitemarrow itemwithtitle:@ "phone sharing" icon:nil option:^{//Call completion will go back to the current app and will not go back to the current app before
Nsurl *url = [Nsurl urlwithstring:@ "tel://1008611"]; //        [[UIApplication sharedapplication] openURL:url];
       
       
        //You will be prompted before calling   back to the current app   private API
//         Nsurl *url = [Nsurl urlwithstring:@ "telprompt://10086"];
//        [[UIApplication sharedapplication] openurl:url];
       
        nsurl *url = [Nsurl urlwithstring:@ "tel://10086"];
        nsurlrequest *request = [Nsurlrequest Requestwithurl:url];
        [Weakself.webview loadrequest:request];
       
   }];
   
Lcitem *item2 = [lcitemarrow itemwithtitle:@ "sms Sharing" Icon:nil option:^{
After sending out the text message. Will go to the SMS interface
Nsurl *url = [Nsurl urlwithstring:@ "sms://hahaha"];
[[UIApplication sharedapplication] openurl:url];


Determine if the device can send information
if (![ Mfmessagecomposeviewcontroller Cansendtext]) {
Return
}

Mfmessagecomposeviewcontroller *VC = [Mfmessagecomposeviewcontroller new];
Recipient list
vc.recipients = @[@ "10000", @ "10086"];
Vc.body = @ "Recommend a NB game http://www.nbcoder.com/test";
Vc.subject = @ "Biaoti";
Set up Proxy
Vc.messagecomposedelegate = weakself;

[Weakself PRESENTVIEWCONTROLLER:VC Animated:yes Completion:nil];

}];
Lcitem *item3 = [Lcitemarrow itemwithtitle:@ "mail sharing" Icon:nil option:^{
Determine if a message can be sent
if (![ Mfmailcomposeviewcontroller Cansendmail]) {
Return
}

Mfmailcomposeviewcontroller *VC = [Mfmailcomposeviewcontroller new];

Vc.mailcomposedelegate = weakself;
Set recipient
[VC settorecipients:@[@][email protected]",@"[email protected]"]];
Secret delivery
[VC setbccrecipients:<# (Nsarray *) #>]
Cc
[VC setccrecipients:<# (Nsarray *) #>]

[VC setsubject:@ "collect benefits"];
[VC setmessagebody:@ "Send Beauty" ishtml:no];

//
UIImage *img = [UIImage imagenamed:@ "AA"];
NSData *data = Uiimagepngrepresentation (IMG);

[VC addattachmentdata:data mimetype:@ "Image/png" filename:@ "Cls.png"];



[Weakself PRESENTVIEWCONTROLLER:VC Animated:yes Completion:nil];

}];

Controller (self)---self.groups---------
Lcgroup *group = [Lcgroup groupwithitems:@[item1,item2,item3]]; Self.groups = @[group];
}

-(void) Mailcomposecontroller: (Mfmailcomposeviewcontroller *) controller didfinishwithresult: (mfmailcomposeresult) Result Error: (Nserror *) error{
[Controller Dismissviewcontrolleranimated:yes Completion:nil];

}


-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) result{
[Controller Dismissviewcontrolleranimated:yes Completion:nil];
}

@end

Call/SMS sharing/email sharing

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.