調用系統 發短信-調用瀏覽器-打電話-跳轉等

發送短信瀏覽器

-(void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients{

    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
    if([MFMessageComposeViewController canSendText])
        
    {
        controller.body = bodyOfMessage;
        controller.recipients = recipients;
        controller.messageComposeDelegate = self;
        [self presentViewController:controller animated:YES completion:nil];
    }else{
    
        [OMGToast KMShowToast:@"該設備不支持短信功能"];
    }
}


- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    [self dismissViewControllerAnimated:YES completion:nil];
    
    if (result == MessageComposeResultCancelled)
    {
        NSLog(@"Message cancelled");
    }
    else if(result == MessageComposeResultSent)
    {
        NSLog(@"Message sent");
    }
    else
    {
        NSLog(@"Message failed");
    }
}

或者直接google

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://9016098909891"]];  //發短信

調用瀏覽器或者跳轉APPStorecode

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; //調用safari打開網頁

打電話ip

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://9016098909891"]];  // 打電話
相關文章
相關標籤/搜索