0

What I'm trying to replicate:

The app 'Cobook Contacts' allows you to select multiple contacts. You can then send a message to these contacts. The app does this by opening the native messages app, and populating it with MULTIPLE NUMBERS.


What I've tried:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:123,456"]];

This only opens messages with the first number populated.


What I Need:

A way to replicate what Cobook Contacts does. Using an MFMessageComposeController is not good enough, I'd like to open the native messaging app. Working example code is bounty worthy.


UPDATE:

I haven't gotten anywhere further, but the object files for the cobook app are actually available at https://cobook.co/open-source. I don't know if it's possible to reverse engineer this to the extent of finding out how they open the message app however.

Binarian
  • 12,296
  • 8
  • 53
  • 84
Jordan Smith
  • 10,310
  • 7
  • 68
  • 114
  • @ScottMcGready already have. No luck. I don't think it's quite as simple as that... although I could be mistaken! The native mail url just uses commas to separate addresses, but sms doesn't seem to work the same. – Jordan Smith Jun 11 '14 at 00:05
  • That's odd, email it's a semicolon. Tried a space (clutching at straws now!) or other standard separators? – ScottMcGready Jun 11 '14 at 00:07
  • @ScottMcGready mail seems to accept any sort of separator then. Yep, space just appends the numbers into one larger number. I don't think it's a straight forward solution somehow. – Jordan Smith Jun 11 '14 at 00:10
  • @Jordan I downloaded Cobook, but I feel stupid and can't figure out how to select multiple contacts for the life of me. Mind explaining quickly? – esqew Jun 11 '14 at 00:11
  • Really odd. Mail accepts it, or at least used to and SMS doesn't. So much for consistency eh? I've just tried a few things (country code separator etc) that didn't work either. Check this out though- http://www.appcoda.com/ios-programming-send-sms-text-message/ – ScottMcGready Jun 11 '14 at 00:16
  • @esqew it's not very user friendly huh. Swipe partially to the right on a contact until the bar goes orange. Let go. Once you've got a few selected like this, hit the orange bar at the bottom and select message. – Jordan Smith Jun 11 '14 at 00:21
  • @ScottMcGready yep, that's pretty much the basics of sending messages, which I've got down packed. Like I said, I don't want to use an MFMessageComposeViewController. Thanks anyway – Jordan Smith Jun 11 '14 at 00:23
  • @Jordan Unfortunately I couldn't reproduce this exact behavior on iOS 8, that is, I couldn't get the orange option to show up. Just the phone (call) and the ellipses (more actions). Nothing indicating sending messages to multiple recipients. Sorry I couldn't be of much help! – esqew Jun 11 '14 at 00:24
  • @esqew ok, you're almost there, don't give up just like that. You've got to swipe only partially to the right. If you swipe too far the ellipses show up. – Jordan Smith Jun 11 '14 at 00:26
  • @Jordan No there is no midway point, it's only two options for me. – esqew Jun 11 '14 at 00:45
  • @esqew I think you might be swiping the wrong way? That will show you a call icon or ellipses if you swipe the whole way. If the other way doesn't work, then I guess it may be an iOS 8 related bug. – Jordan Smith Jun 11 '14 at 00:51
  • @Jordan Ah yes, I was swiping the wrong way. I'll take a peek. – esqew Jun 11 '14 at 00:54
  • @Jordan Very interesting behavior. Can't seem reproduce with any combination of the `sms` schema, but Cobook seems to do it just fine. – esqew Jun 11 '14 at 02:15
  • @esqew Yeah. I'd almost pay someone that could show me whatever trick they use. For now let's just keep it at a bounty, but I'm very interested in reproducing the behaviour. – Jordan Smith Jun 11 '14 at 02:20
  • Ok I have tried to reverse engineer the app and so far I have found 3 strings which open the message app: sms: sms:%@ sms:/open?addresses=%@ but none of them worked so far – gallileo Jun 11 '14 at 08:35
  • @DJ_Lectr0 nice work. I tried to do that but failed miserably, do you mind explaining briefly how you went about doing this? – Jordan Smith Jun 11 '14 at 11:02
  • @Jordan use this command: strings binaryname | grep -i searchstring in your case binaryname would be libCobook-main.a and searchstring sms: – gallileo Jun 11 '14 at 14:13

1 Answers1

6

I also worked on the code of the app (also credit to DJ_Lectr0 in the comments) and found that this works:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:/open?addresses=555.234.5678,555.234.5454;body=Hello,%20World"]];

This allows you to specify multiple addresses (phone numbers) as well as add a body (which you can obviously leave off)!

Some interesting and related material. This is the only real documentation about opening the SMS from Apple that I could find. It neither specifies the body argument or multiple addressees, but does show you the different string formats/characters you can use. This SO answer also got me thinking about using an argument (in this case it ended up being addresses although I tried about a hundred different things) and was where I found the body option.

This is what I ended up with when I use the exact code above:

enter image description here

Community
  • 1
  • 1
Firo
  • 15,448
  • 3
  • 54
  • 74
  • You found this by trial and error... wow, that is some serious dedication! There are quite a few forum posts etc asking how to do this, and everyone is stumped. Kudos to you. That is quite a find! – Jordan Smith Jun 11 '14 at 11:03
  • For anyone else trying this, I'll be nice and save you the hassle. Whitespace characters seem to mess this up and don't launch anything. Remove them from your numbers and you're set. – Jordan Smith Jun 11 '14 at 11:05
  • The body argument doesn't seem to work - is there any trick to this? – Jordan Smith Jun 11 '14 at 11:11
  • @Jordan, Glad it is partly working for you! Yeah, it does not seem to like whitespace. I added an image of what you should see. Does yours not pre-fill the text when you use the exact code above? – Firo Jun 11 '14 at 11:50
  • @Firo no it doesn't seem to, I'm using an iPhone as opposed to an iPad, and even copy pasting the exact string above doesn't fill out any of the message. It'd be nice to get it working, but it's by no means the end of the world if it doesn't work. – Jordan Smith Jun 11 '14 at 12:00
  • @Jordan, try going to the [second](http://stackoverflow.com/questions/6480462/how-to-pre-populate-the-sms-body-text-via-an-html-link/19126326#19126326) link I provided in my answer, and see the [test site](http://bradorego.com/test/sms.html) that the answer links to. Do any of those examples work for you? Sorry, but I do not have an iPhone, so I cannot help you much. – Firo Jun 11 '14 at 14:20
  • @Firo no none of those work for me. Tested on my iPad though and it works fine - so for some reason, it's limited to iPad only (unless there's a trick to getting it working on iPhone). – Jordan Smith Jun 11 '14 at 23:10
  • @Jordan, weird. I will try a few things, but am doubtful I will find anything. – Firo Jun 12 '14 at 18:37