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

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

相关推荐
恋猫de小郭9 小时前
什么?Flutter 可能会被 SwiftUI/ArkUI 化?全新的 Flutter Roadmap
flutter·ios·swiftui
网安墨雨13 小时前
iOS应用网络安全之HTTPS
web安全·ios·https
福大大架构师每日一题15 小时前
37.1 prometheus管理接口源码讲解
ios·iphone·prometheus
Json_1817901448019 小时前
淘系商品评论json数据示例参考,API接口系列
大数据·json·api
BangRaJun1 天前
LNCollectionView-替换幂率流体
算法·ios·设计
刘小哈哈哈1 天前
iOS 多个输入框弹出键盘处理
macos·ios·cocoa
靴子学长1 天前
iOS + watchOS Tourism App(含源码可简单复现)
mysql·ios·swiftui
北京_宏哥2 天前
python接口自动化(三十五)-封装与调用--流程类接口关联(详解)
前端·python·api
一如初夏丿2 天前
xcode15 报错 does not contain ‘libarclite‘
ios·xcode
杨武博2 天前
ios 混合开发应用白屏问题
ios