Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending an iMessage as simple as possible iOS

I want to be able to programmatically send an iMessage without anything else being done except calling a function that will send a text to a number with a message, both of which are text boxes. I'd really appreciate some sample code as I've hunted the net but nothing I've found will help. This is not for a commercial app, just me so it can use Private frameworks, or anything that will do the job. Thanks.

like image 911
Jordan Avatar asked Jun 01 '12 12:06

Jordan


People also ask

How do you send a simple text instead of iMessage?

To send a traditional text rather than through iMessage on a per-message basis, just do the following on your iPhone: Tap and hold on the message you want to send as a text. From the pop-up menu, select “Send as Text Message”

How do you send an iMessage instead of a text message iOS 15?

Open the Settings app, scroll down and tap the option for 'Messages'. Then, scroll down and turn off the toggle for 'Send as SMS'. Now, any messages you send to your Apple contacts will only go as an iMessage.


1 Answers

The only way to send a message is to the MessageUI framework. There is an example of how to do this in the iOS documentation:

https://developer.apple.com/library/ios/#samplecode/MessageComposer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010161

Edit: I just noticed this question is a duplicate of this: how to use MessageUI framework to send iMessage messages on iPhone

Correction: It appears that you can use CoreTelephony to send a message:

[[CTMessageCenter sharedMessageCenter] sendSMSWithText:message serviceCenter:nil toAddress:number];

The comment from Jordan Brown led me to this. I do suspect that this might get you banned from the App Store, but I know you said you aren't concerned with that.

like image 141
woz Avatar answered Oct 07 '22 01:10

woz