سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top