【代码笔记】短信分享

代码:

ViewController.h

#import <UIKit/UIKit.h>
//短信分享
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MFMessageComposeViewController.h>

@interface ViewController : UIViewController<MFMessageComposeViewControllerDelegate>

@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
//点击任何处,短信分享
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

    //调用系统发送信息功能
    BOOL canSendSMS = [MFMessageComposeViewController canSendText];
    if (canSendSMS) {

        MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
        picker.messageComposeDelegate = self;

        NSArray *array = [[NSArray alloc] initWithObjects:nil];
        picker.recipients=array;
        picker.view.frame=CGRectMake(0, 0, 320, 640);
        [self presentViewController:picker animated:YES completion:nil];

    }else{
        UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@""
                                                      message:@"当前设备不支持短信功能"
                                                     delegate:nil
                                            cancelButtonTitle:@"确定"
                                            otherButtonTitles:nil];
        [alert show];
    }

}
#pragma -mark -系统消息回调
//系统发送信息的回调函数
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{

    //[self dismissModalViewControllerAnimated:YES];
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

时间: 2024-08-03 23:32:31

【代码笔记】短信分享的相关文章

Android APP代码拨打电话和短信分享

Android APP拨打电话: Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+888888)); startActivity(intent); } Android APP短信分享: Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", "#短信分享#");

解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人

问题描述: [操作步骤]:People下导入导出中选择分享可见联系人,选择多个联系人后通过短信分享 [测试结果]:短信中只能显示一个联系人 [预期结果]:可以显示多个联系人 经过代码分析,从compose_message_activitu.xml中的ViewStub进行定位到现实联系人名片的视图: <ViewStub android:id="@+id/vcard_attachment_view_stub" android:layout="@layout/vcard_at

打电话/短信分享/邮件分享

//  Created by apple on 15/6/17. //  Copyright (c) 2015年 Super All rights reserved. // #import "LCShareController.h" #import <MessageUI/MessageUI.h> @interface LCShareController () <MFMessageComposeViewControllerDelegate,MFMailComposeVi

基于android 社区app短信分享 发送回调事件实现

概要 前段时间,因为项目的需要,使用ShareSDK的分享功能,其中包括 短信分享吗,并且在调用系统短信分享成功后要与服务器进行交互处理(我这里不关心,对方能否收到,只关心发出去了).但是ShareSDk并不支持短信分享的回调功能,咨询了技术客服,也没有讨论出解决方案来.于是自己尝试粗略实现了一下. 方法 在调用系统短信发送后,通过内容观察者监听 短信发件箱的改变,如果监听到有内容改变的短信ID,那么获取当前的内容并检测其中是否含有某些关键字( 当然,这个关键字是我们自己定义的,例如:"jarl

iOS sharedk短信分享

今天做短信分享和拷贝分享的时候突然发现他们跟微博分享是不太一样的,短信分享是只支持内容,拷贝是支持图片和内容他们是不支持链接的,如果你想让他们有链接只能把链接写入内容之中 微博及微信等分享内容的写入 id<ISSContent> publishContent = [ShareSDK content:[self.contentDic objectForKey:@"title"] defaultContent:@"请添加分享内容" image:[ShareS

iOS使用邮件、短信分享回调报错UIApplicationInvalidInterfaceOrientation

iOS中使用系统的邮件.短信分享之后,如果该页面是禁止转屏的,那么可能不会出现问题,如果是设置为允许转屏,那么如果你的- (NSUInteger)supportedInterfaceOrientations方法返回值不是UIInterfaceOrientationMaskAll,那么可能会报Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferred

基于android 社会的app短信分享 发送回调事件的实现

摘要 前一段时间.由于项目的需要,采用ShareSDK该共享功能.其中包含 短信股吧.和呼叫系统,以分享要与成功处理服务器交互的消息后,(我不在乎在这里,收到.仅仅关心发出去了).可是ShareSDk并不支持短信分享的回调功能,咨询了技术客服,也没有讨论出解决方式来.于是自己尝试粗略实现了一下. 方法 在调用系统短信发送后,通过内容观察者监听 短信发件箱的改变,假设监听到有内容改变的短信ID,那么获取当前的内容并检測当中是否含有某些关键字( 当然,这个关键字是我们自定义的.比如:"jarlen&

iOS 短信分享 邮件分享

本地调用短信分享. 1 #import "shareViewController.h" 2 3 @interface shareViewController (){ 4 UIAlertView *mfAlertview;//定义一个弹出框 5 UITextView* txYaoqingma; 6 } 7 8 @end 9 10 @implementation shareViewController 11 12 - (void)viewDidLoad { 13 [super viewDi

Cocos2d-x3.3RC0通过JNI调用Android的Java层URI代码发送短信

1.Jni不在赘述.翻看前面博客 2.直接上代码 1)Java层,直接加在AppActivity.java中 public class AppActivity extends Cocos2dxActivity{ public static Activity acty; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); acty = this; } static { Sy