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