Prowtons McBishop desires to attract extra consideration to this query.
I’m constructing an iMessage extension app that I don’t intend to undergo the App Retailer. This app goals to ship a scheduled SMS message given a date and time. Does the iOS atmosphere provide a technique to ship SMS messages from a background thread? I’ve carried out analysis, nevertheless, many of the data I’ve come throughout is now a few years outdated. I’ve tried to make use of the activeConversation occasion member variable of the MSMessagesAppViewController class to ship an SMS message, nevertheless, this has points when executing on a background thread. In my very own analysis I’ve seen two extra strategies of sending SMS messages, particularly, ChatKit & CTMessageCenter. I’ve tried the CTMessageCenter method however to no avail. I have no idea hyperlink the personal headers from CTMessageCenter so as an alternative I exploit NSInvocation to work together with CTMessageCenter. I’ll present an Goal-C code snippet.
void sendSMS(NSObject* receiver, NSString* message, NSString* phoneNumber) {
SEL selector = @selector(sendSMSWithText:serviceCenter:toAddress:);
NSMethodSignature* signature = [receiver methodSignatureForSelector:selector];
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:receiver];
[invocation setSelector:selector];
[invocation setArgument:&message atIndex:2];
[invocation setArgument:&(NSObject*) { nil } atIndex:3];
[invocation setArgument:&phoneNumber atIndex:4];
printf(“Earlier than.n”);
[invocation invoke];
printf(“After.n”);
}
I name the code from Swift like this:
let receiver = (NSClassFromString(“CTMessageCenter”)! as AnyObject)
.carry out(NSSelectorFromString(“sharedMessageCenter”))
.takeUnretainedValue() as! NSObject
sendSMS(receiver, “Your program labored!”, “+10000000000”)
Right here is the output that I’m met with within the console.
I’ve not tried the ChatKit method, nevertheless, the iPhone Dev Wiki leads me to assume that this isn’t an possibility for me since a number of the API could solely be used from the MobileSMS (iMessage) course of. That data could also be discovered right here.
Does anybody know if I’m doing one thing mistaken or if there may be one other technique to ship SMS messages? In any other case, are there any open supply tasks that illustrate comparable performance that I’ll check out? Thanks for any and all assist.