iOS-打電話、發簡訊、發郵件【指定QQ使用者發送QQ訊息】,ios-訊息

來源:互聯網
上載者:User

iOS-打電話、發簡訊、發郵件【指定QQ使用者發送QQ訊息】,ios-訊息
1.發簡訊

標頭檔

#import <MessageUI/MessageUI.h>

頭部代理

@interface ViewController ()<MFMessageComposeViewControllerDelegate>

發送資訊

- (void)senderMessage{    if([MFMessageComposeViewController canSendText]) {        ///簡訊執行個體化        MFMessageComposeViewController * messageVc = [[MFMessageComposeViewController alloc] init];        ///目標號碼,可以多個        messageVc.recipients = @[@"18888888888",@"15555555555"];        messageVc.navigationBar.tintColor = [UIColor redColor];        messageVc.body = @"發送的內容-發送的內容-發送的內容";        messageVc.messageComposeDelegate = self;        [self presentViewController:messageVc animated:YES completion:nil];        [[[[messageVc viewControllers] lastObject] navigationItem] setTitle:@"title"];    }    else {        NSLog(@"當前裝置不支援簡訊功能");    }    }

代理方法實現

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {    ///dismiss MFMessageComposeViewController    [controller dismissViewControllerAnimated:YES completion:nil];    if (result == MessageComposeResultSent) {        NSLog(@"資訊發送成功!");    }    else if (result == MessageComposeResultFailed){        NSLog(@"資訊發送失敗!");    }    else if (result == MessageComposeResultCancelled){        NSLog(@"點擊了取消");    }    else{            }}
2.撥打到電話
- (void)dialPhone{    ///該方法直接撥打,不會彈出呼叫(取消)    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://18888888888"]];        ///該方法會彈出是否取消呼叫    UIWebView*callWebview =[[UIWebView alloc] init];    NSURL *telURL =[NSURL URLWithString:@"tel:18888888888"];    [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];    [self.view addSubview:callWebview];}
3.發送郵件
- (void)senderEmail{    NSString *urlStr =@"mailto:xxxxxxxx@xxxx.com?subject=郵件主題(此參數可不傳)&body=郵件內容(此參數可不傳)";    NSURL *url = [NSURL URLWithString:urlStr] ;    [[UIApplication sharedApplication] openURL:url];}
4.發送QQ訊息
- (void)senderQQ{    ///111111111111為QQ號碼    NSString *url = @"mqq://im/chat?chat_type=wpa&uin=111111111111&version=1&src_type=web";    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];}

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.