蘋果的微信
協議:MFMessageComposeViewControllerDelegate(信息),MFMailComposeViewControllerDelegate(郵箱)
1(信息)
//須要真機,虛擬機沒效果
if ([MFMessageComposeViewController canSendText]) {
//檢測 當前應用 是否支持短信功能
//支持的話 建立 具備短信模塊的界面
MFMessageComposeViewController *message = [[MFMessageComposeViewController alloc] init];
//設置聯繫人 (能夠羣發)
message.recipients = @[@"10086",@"10011"];
//設置短信的內容
message.body = [NSString stringWithFormat:@"快來下載,這裏有驚喜:%@「,@「網址」];
message.messageComposeDelegate = self;
//模態跳轉(內部有導航)
[self presentViewController:message animated:YES completion:nil];
}
//協議
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
switch (result) {
case MessageComposeResultCancelled:
{
NSLog(@"取消");
}
break;
case MessageComposeResultSent:
{
NSLog(@"短信已發送");
}
break;
case MessageComposeResultFailed:
{
NSLog(@"短信失敗");
}
break;
default:
break;
}
//最後要模態跳轉返回
[controller dismissViewControllerAnimated:YES completion:nil];
}
(2)郵箱
if ([MFMailComposeViewController canSendMail]) {
//檢測是否支持郵箱功能
//若是支持 建立界面
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
//設置聯繫人
[mail setToRecipients:@[@"xxxxx@qq.com」,@「zzzz@163.com"]];
//設置抄送
[mail setCcRecipients:@[@"xxx@sina.com"]];
//設置標題
[mail setSubject:@"分享愛限免應用"];
//設置內容
NSString *str = [NSString stringWithFormat:@"點擊有驚喜:%@「,@「網址」];
//第二個參數 是否以HTML格式
[mail setMessageBody:str isHTML:YES];
//添加附件
NSData *data = UIImagePNGRepresentation([UIImage imageNamed: @"account_candou"]);
//第一個參數 文件二進制 2 文件的類型 3 文件的名字
[mail addAttachmentData:data mimeType:@"image/png" fileName:@"account_candou"];
//設置代理
mail.mailComposeDelegate = self;
//模態跳轉
[self presentViewController:mail animated:YES completion:nil];
}
//協議
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
switch (result) {
case MFMailComposeResultCancelled:
NSLog(@"郵件取消");
break;
case MFMailComposeResultSaved:
NSLog(@"郵件保存");
break;
case MFMailComposeResultSent:
NSLog(@"郵件發送");
break;
case MFMailComposeResultFailed:
NSLog(@"郵件失敗");
break;
default:
break;
}
//模態跳轉返回
[self dismissViewControllerAnimated:YES completion:nil];
}app
友盟的
spa
//協議
UMSocialUIDelegate
[UMSocialSnsService presentSnsIconSheetView:self appKey:@"507fcab25270157b37000010" shareText:str shareImage:[UIImage imageNamed: @"account_candou"] shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToSms,UMShareToEmail,UMShareToWechatTimeline,nil] delegate:self];(寫了這麼多也就前三個有用微信須要本身去註冊)
在appdelgete.m中(其餘的,哎都是淚看文檔把,你妹的呀)
//初始化UM
- (void)initUM {
//初始化
[UMSocialData setAppKey:@"507fcab25270157b37000010"];
}
代理