代码库> 系统功能> 求iphone自动发送短信代码
求iphone自动发送短信代码
关注
查看次数:8930 下载次数:0
上传时间:2013-04-10 大小:
[table=100%][tr][td]以下是大家常见发送信息的代码,是在程序里面弹出一个发送短信的sheet出来,然后要按发送按钮发送。可是我想它能够自动发送(包括后台也能发送),除了私有方法,应该如何实现?@interface SMSComposer : MFMessageComposeViewController <MFMessageComposeViewControllerDelegate>
[/td][/tr][tr][td]{
[/td][/tr][tr][td]    BOOL _autoSend;
[/td][/tr][tr][td]}
[/td][/tr][tr][td]@property(nonatomic) BOOL autoSend;
[/td][/tr][tr][td]+ (id)composerWithBody:(NSString *)body to:(NSArray *)recipients;
[/td][/tr][tr][td]@end[table=100%][tr][td]// Compose SMS
[/td][/tr][tr][td]+ (id)composerWithBody:(NSString *)body to:(NSArray *)recipients
[/td][/tr][tr][td]{
[/td][/tr][tr][td]    // Check
[/td][/tr][tr][td]    if ([MFMessageComposeViewController canSendText] == NO)
[/td][/tr][tr][td]    {
[/td][/tr][tr][td]        [UIAlertView alertWithTitle:NSLocalizedString(@"Could not send SMS on this device.", @"在此设备上无法发送短信。")];
[/td][/tr][tr][td]        return nil;
[/td][/tr][tr][td]    }
[/td][/tr][tr][td]    
[/td][/tr][tr][td]    // Display composer
[/td][/tr][tr][td]    SMSComposer *composer = [[[SMSComposer alloc] init] autorelease];
[/td][/tr][tr][td]    composer.messageComposeDelegate = composer;
[/td][/tr][tr][td]    if (body) composer.body = body;
[/td][/tr][tr][td]    if (recipients) composer.recipients = recipients;
[/td][/tr][tr][td]    return composer;
[/td][/tr][tr][td]}[/td][/tr][/table][table=100%][tr][td]// The user's completion of message composition.
[/td][/tr][tr][td]- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result;
[/td][/tr][tr][td]{
[/td][/tr][tr][td]    if (result == MessageComposeResultFailed)
[/td][/tr][tr][td]    {
[/td][/tr][tr][td]        [UIAlertView alertWithTitle:NSLocalizedString(@"Failed to send SMS.", @"发送短信失败。")];
[/td][/tr][tr][td]    }
[/td][/tr][tr][td]    else
[/td][/tr][tr][td]    {
[/td][/tr][tr][td]        [self dismissModalViewControllerAnimated:!_autoSend];
[/td][/tr][tr][td]        
[/td][/tr][tr][td]        if ((result == MessageComposeResultSent) && _autoSend)
[/td][/tr][tr][td]        {
[/td][/tr][tr][td]            [UIAlertView alertWithTitle:NSLocalizedString(@"Send SMS successfully.", @"发送短信成功。")];
[/td][/tr][tr][td]        }
[/td][/tr][tr][td]    }
[/td][/tr][tr][td]}[/td][/tr][/table][/td][/tr][/table]
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0
下载过该代码的还下载了
本周热门下载
综合评论
提示
sina weixin mail 回到顶部