0

Currently,I am developing an app to track iPhone, so when the app is starting, the current location is automatically sent to the Recipient as a text message.

I have used the below code for sending message, but it is for MFMessageComposeViewController. I have no idea about how to send message without presenting MFMessageComposeViewController. So need some guidance on how this can be achieved. Here is the code :

 NSArray *recipents = @[@"8866210464", @"9276820096"];
NSString *message = locationString;   //String for current Location

MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate=self;
[messageController setRecipients:recipents];
[messageController setBody:message];

[self presentViewController:messageController animated:NO completion:nil];

Thanks.

Krunal
  • 77,632
  • 48
  • 245
  • 261
Rakesh Thummar
  • 197
  • 1
  • 2
  • 11

2 Answers2

2

No, not possible. This is to protect the user's privacy.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
0

You can't do it without MFMessageComposeViewController. Apple won't allow to send SMS without user interaction.

I've alternate solution of this, out of scope of iOS:

Use web service API. Create a web service at server side that send a message to specific number(s) that accept numbers as parameters with request.

At specific time interval (according to your requirement) send a web service call with number as request parameter.

Web server can do it. It can send message to any device.

Krunal
  • 77,632
  • 48
  • 245
  • 261