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

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

相关推荐
dr李四维7 分钟前
iOS构建版本以及Hbuilder打iOS的ipa包全流程
前端·笔记·ios·产品运营·产品经理·xcode
️ 邪神14 分钟前
【Android、IOS、Flutter、鸿蒙、ReactNative 】自定义View
flutter·ios·鸿蒙·reactnative·anroid
比格丽巴格丽抱12 小时前
flutter项目苹果编译运行打包上线
flutter·ios
网络安全-老纪13 小时前
iOS应用网络安全之HTTPS
web安全·ios·https
1024小神16 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
lzhdim17 小时前
iPhone 17 Air看点汇总:薄至6mm 刷新苹果轻薄纪录
ios·iphone
安和昂17 小时前
【iOS】知乎日报第四周总结
ios
一条晒干的咸魚18 小时前
【Web前端】实现基于 Promise 的 API:alarm API
开发语言·前端·javascript·api·promise
麦田里的守望者江19 小时前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
_黎明21 小时前
【Swift】字符串和字符
开发语言·ios·swift