I have been trying to do this on iOS 6.1 for way long and as I figured out eventually this method could not be used since iOS 6. Last time I could make this code execute successfully was on iOS 5 (there is a Peanut.app on the web working).
What actually worked is what can be found here and discussed here as well with the following code block.
dispatch_queue_t queue = dispatch_queue_create("com.apple.chatkit.clientcomposeserver.xpc_connection_queue", DISPATCH_QUEUE_SERIAL);
xpc_connection_t connection = xpc_connection_create_mach_service("com.apple.chatkit.clientcomposeserver.xpc", queue, 0);
xpc_connection_set_event_handler(connection, ^(xpc_object_t){});
xpc_connection_resume(connection);
dispatch_release(queue);
xpc_object_t dictionary = xpc_dictionary_create(0, 0, 0);
xpc_dictionary_set_int64(dictionary, "message-type", 0);
NSData* recipients = [NSPropertyListSerialization dataWithPropertyList:[NSArray arrayWithObject:@"12212"] format:NSPropertyListBinaryFormat_v1_0 options:0 error:NULL];
xpc_dictionary_set_data(dictionary, "recipients", recipients.bytes, recipients.length);
xpc_dictionary_set_string(dictionary, "markup", "SMS text");
xpc_connection_send_message(connection, dictionary);
xpc_release(dictionary);
Haven't tried to implement on non-jailbreak iOS though. I hope you can make it!
** EDIT
Let me correct myself! Your code does work on a jailbreak tweak using the imagent
executable. Just couldn't execute it straight from an xCode app.