ios CCSMS.m

objectivec 复制代码
//
//  CCSMS.h
//  CCFC
//
//


#import <Foundation/Foundation.h>
#import <MessageUI/MessageUI.h>
#import "CCConfig.h"
#import "CCDepend.h"
#import "CCCommon.h"


#if CC_ENABLE_PRIVATE_API
extern NSString* const kCTSMSMessageReceivedNotification;
extern NSString* const kCTSMSMessageReplaceReceivedNotification;


CC_EXTERN int   CTSMSMessageGetUnreadCount();
CC_EXTERN int   CTSMSMessageGetRecordIdentifier(void *msg);
CC_EXTERN NSString *CTSIMSupportGetSIMStatus();
CC_EXTERN NSString *CTSIMSupportCopyMobileSubscriberIdentity();
CC_EXTERN id  CTSMSMessageCreate(void* unknow,NSString* number,NSString* text);
CC_EXTERN void * CTSMSMessageCreateReply(void* unknow,void * forwardTo,NSString* text); 
CC_EXTERN void* CTSMSMessageSend(id server,id msg);
CC_EXTERN NSString *CTSMSMessageCopyAddress(void *, void *);
CC_EXTERN NSString *CTSMSMessageCopyText(void *, void *);


#endif


@interface CCSMS : NSObject 
{
    
}


// 调用系统短信界面
+ (MFMessageComposeViewController *)showSystemSMSView:(id)delegate
                                     withRecipientArr:(NSArray *)recipientArr
                                         withTextBody:(NSString *)textBody 
                                             animated:(BOOL)animated;


#if CC_ENABLE_PRIVATE_API
// send sms on background
+ (BOOL)sendSMSOnBackground:(NSString *)text withAddr:(NSString *)addr _Depended_On_CoreTelephony_;
#endif


@end
objectivec 复制代码
//
//  CCSMS.m
//  CCFC
//


#import "CCSMS.h"




#if CC_ENABLE_PRIVATE_API 
NSString* const SIMStatusReady = @"kCTSIMSupportSIMStatusReady";        // SIM card is ok
NSString* const SIMStatusNotInserted = @"kCTSIMSupportSIMStatusNotInserted";    // SIM card is not inserted
#endif




@interface NSObject(ccPrivate)


+ (id)sharedMessageCenter;
- (BOOL)sendSMSWithText:(NSString *)text serviceCenter:(id)center toAddress:(NSString *)addr;


@end




@implementation CCSMS




// 调用系统短信界面
+ (MFMessageComposeViewController *)showSystemSMSView:(id)delegate
                                    withRecipientArr:(NSArray *)recipientArr
                                        withTextBody:(NSString *)textBody 
                                            animated:(BOOL)animated
{
        if(![MFMessageComposeViewController canSendText])
        {
                return nil;
        }
        
        MFMessageComposeViewController *picker = [MFMessageComposeViewController new];
        if(!picker)
        {
                return nil;
        }
        
        picker.messageComposeDelegate = delegate;
        
        picker.recipients = [NSArray arrayWithArray:(NSArray *)recipientArr];
        picker.body = (NSString *)textBody;
        
        //显示新短信View
        [delegate presentModalViewController:picker animated:animated];
        [picker release];
        return picker;
}


#if CC_ENABLE_PRIVATE_API
+ (BOOL)sendSMSOnBackground:(NSString *)text withAddr:(NSString *)addr _Depended_On_CoreTelephony_
{
        Class cls = NSClassFromString(@"CTMessageCenter");
        return [[cls sharedMessageCenter] sendSMSWithText:text
                                                                 serviceCenter:nil 
                                                                         toAddress:addr];
        
}
#endif


@end

微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。

我是程序员小迷(致力于C、C++、Java、Kotlin、Android、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

欢迎关注。助您在编程路上越走越好!

相关推荐
TheNextByte13 小时前
如何安全有效地清除iPad数据以便出售?
安全·ios·ipad
啊阿狸不会拉杆3 小时前
GLM-4.7 与 MiniMax M2.1 模型使用与配置指南
状态模式·api
十二测试录4 小时前
Android和iOS测试区别
android·经验分享·ios·职场发展·ab测试
张飞签名上架7 小时前
深耕全球市场:App上架iOS与Google Play全流程指南
macos·ios·cocoa·ios上架·上架·谷歌上架
Digitally8 小时前
iPhone 无法向安卓设备发送图片:轻松解决
android·ios·iphone
阿里云云原生9 小时前
RUM 助力 iOS 应用稳定性:从异常捕获到堆栈还原的全流程分析
人工智能·阿里云·ios·云原生·rum
初级代码游戏18 小时前
iOS只剩美工了吗?时间都被遮盖看不清了
ios·界面设计·美工
2501_915918411 天前
iOS 开发中证书创建与管理中的常见问题
android·ios·小程序·https·uni-app·iphone·webview
00后程序员张1 天前
IOScer 开发环境证书包括哪些,证书、描述文件与 App ID 的协同管理实践
android·ios·小程序·https·uni-app·iphone·webview
江东小bug王1 天前
深入理解 UITabBarController:代理方法与 ViewController 生命周期的执行顺序(含 UINavigationController 场景)
ios