0

我有一个紧急呼叫应用程序。当用户按下联系人时,它会呼叫他们。然后用户必须返回应用程序发送自动短信。但是,我希望当按下联系人时,用户会被带到消息框架,一旦按下发送,它就会呼叫该人。这是到目前为止的代码。

- (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]);
}

对此的任何解决方案将不胜感激。

4

1 回答 1

3

你正在做的:

messageComposer.messageComposeDelegate = self;

只需定义:

messageComposeViewController:didFinishWithResult

当有人完成编辑文本时将调用它,您可以从第二个参数中获取结果。

MessageComposeResultCancelled,
MessageComposeResultSent,
MessageComposeResultFailed

您可以通过此回调拨打电话。

要拨打电话,请使用:

NSString *phoneNumber = [@"telprompt://" stringByAppendingString:@"123123123"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];

或 tel:// 无需提示即可拨打电话。

于 2013-09-11T15:51:33.370 回答