我是iphone应用开发新手。如何在特定时间发送短信
我正在创建一个应用程序来发送短信。
在我的应用程序中,我需要在指定的时间发送短信。
我有一个时间选择器来指定在UITextField中的时间。 (无效)sendInAppSMS { NSLog(@“SendMessage”);
if([textFieldRounded.text isEqualToString:@""] || [textFieldRounded1.text isEqualToString:@""] || [textFieldRounded2.text isEqualToString:@""] || [textFieldRounded.text isEqualToString:@"(null)"] || [textFieldRounded1.text isEqualToString:@"(null)"] || [textFieldRounded1.text isEqualToString:@"(null)"] || [textFieldRounded.text isEqualToString:nil] || [textFieldRounded1.text isEqualToString:nil]|| [textFieldRounded2.text isEqualToString:nil])
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"SMS" message:@"Please Enter All Fields!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
else
{
NSLog(@"Done");
NSDateFormatter *SentTime = [[NSDateFormatter alloc] init];
[SentTime setDateFormat:@"dd/MM/YYYY hh:mm aa"];
NSDate *now1 = [NSDate date];
NSString *Time1 = [SentTime stringFromDate:now1];
NSLog(@"Time is :%@",Time1);
NSString *Sentime=[NSString stringWithFormat:@"%@",textFieldRounded2.text];
if([Sentime isEqualToString:Time1])
{
NSLog(@"Time Matching... can send msg now");
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
NSString *Message = [NSString stringWithFormat:@"%@, %@",textFieldRounded1.text,textFieldRounded2.text];
NSLog(@"Message is %@", Message);
controller.body = Message;
controller.recipients = [NSArray arrayWithObjects:@"+919999999999" , nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
else
{
NSLog(@"Send Message when time reach at %@",textFieldRounded2.text);
//Here What code i should write
}
}
}
如果时间等于当前时间,然后发送短信nowitself(无需存储任何地方的讯息话题)。
其他明智的我需要发送短信,当前时间成为指定的时间。直到达到如何保存(存储)消息并发送的时间。
问候,
Rajendran.B
plz分享你的努力,并写一些你做的代码。 – Milind
textFieldRounded2。文本包含指定的时间... – Rajendran