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等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

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

相关推荐
胖虎15 小时前
实现 iOS 自定义高斯模糊文字效果的 UILabel(文末有Demo)
ios·高斯模糊文字·模糊文字
_可乐无糖2 天前
Appium 检查安装的驱动
android·ui·ios·appium·自动化
胖虎12 天前
iOS 网络请求: Alamofire 结合 ObjectMapper 实现自动解析
ios·alamofire·objectmapper·网络请求自动解析·数据自动解析模型
开发者如是说2 天前
破茧英语路:我的经验与自研软件
ios·创业·推广
假装自己很用心2 天前
iOS 内购接入StoreKit2 及低与iOS 15 版本StoreKit 1 兼容方案实现
ios·swift·storekit·storekit2
iOS阿玮2 天前
“小红书”海外版正式更名“ rednote”,突然爆红的背后带给开发者哪些思考?
ios·app·apple
lichong9513 天前
【React】win系统环境搭建
前端·react.js·前端框架·api·postman·win·smartapi
刘小哈哈哈3 天前
iOS UIScrollView的一个特性
macos·ios·cocoa
忆江南的博客4 天前
iOS 性能优化:实战案例分享
ios
忆江南的博客4 天前
深入剖析iOS网络优化策略,提升App性能
ios