我有一个紧急调用应用程序。当用户按下联系人时,它会调用他们。然后用户必须返回到应用程序以发送自动短信。但是我希望当按下联系人时,用户会被带到消息框架,一旦按下发送,它就会调用该人。这是到目前为止的代码。
- (NSString *)deviceLocation {
return [NSString stringWithFormat:@"Hi, you have been contacted as there has been an emergancy. Here is the location of the caller: Latitude: %f Longitude: %f . Please call for help to that location. From Kiddy Call the iPhone app. ", locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude];
}
#pragma mark - PictureListMainTableCellDelegate methods
-(void)pictureListMainTableCell:(PictureListMainTableCell *)cell wantsToCallNumber:(NSString *)number
{
if([MFMessageComposeViewController canSendText])
{
MFMessageComposeViewController *messageComposer =
[[MFMessageComposeViewController alloc] init];
NSString *message = (@"%@", [self deviceLocation]);
[messageComposer setBody:message];
messageComposer.recipients = [NSArray arrayWithObjects:number , nil];
messageComposer.messageComposeDelegate = self;
[self presentViewController:messageComposer animated:YES completion:nil];
NSLog(@"Texting telephone number [%@]", messageComposer);
}
NSString *urlString = [NSString stringWithFormat:@"tel://%@", number];
NSLog(@"calling telephone number [%@]", number);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
NSLog(@"%@", [self deviceLocation]);
}
对此的任何解决方案将不胜感激。
最佳答案
你在做:
messageComposer.messageComposeDelegate = self;
只需定义:
messageComposeViewController:didFinishWithResult
当有人完成编辑文本时调用它,您可以从第二个参数中获取结果。
MessageComposeResultCancelled,
MessageComposeResultSent,
MessageComposeResultFailed
您可以从这个回调中调用电话。
调用电话:
NSString *phoneNumber = [@"telprompt://" stringByAppendingString:@"123123123"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
或 tel://用于在没有提示的情况下调用电话。
关于iphone - 发送文本然后调用联系人 iPhone 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18745137/