私はiPhoneアプリケーション開発に不慣れです。
私はSMSを送信するためのアプリケーションを作成しています。
私のアプリケーションでは、指定された時間にSMSを送信する必要があります。
UITextFieldで時間を指定するタイムピッカーがあります。
-(void)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
}
}
}
時間が現在の時間と等しい場合は、今すぐSMSを送信します(メッセージをどこかに保存する必要はありません)。
それ以外の場合は、現在の時刻が指定された時刻になったときに、そのSMSを送信する必要があります。時間に達するまで、メッセージを保持(保存)して時間どおりに送信する方法。
よろしく、
Rajendran.B