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.
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”
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With