Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sms.m - Fixes the main thread issue (dispatch_async) #219

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/ios/Sms.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ - (void)send:(CDVInvokedUrlCommand*)command {
return;
}

MFMessageComposeViewController *composeViewController = [[MFMessageComposeViewController alloc] init];
composeViewController.messageComposeDelegate = self;
dispatch_async(dispatch_get_main_queue(), ^{
MFMessageComposeViewController *composeViewController = [[MFMessageComposeViewController alloc] init];
composeViewController.messageComposeDelegate = self;

NSString* body = [command.arguments objectAtIndex:1];
if (body != nil) {
BOOL replaceLineBreaks = [[command.arguments objectAtIndex:3] boolValue];
if (replaceLineBreaks) {
body = [body stringByReplacingOccurrencesOfString: @"\\n" withString: @"\n"];
NSString* body = [command.arguments objectAtIndex:1];
if (body != nil) {
BOOL replaceLineBreaks = [[command.arguments objectAtIndex:3] boolValue];
if (replaceLineBreaks) {
body = [body stringByReplacingOccurrencesOfString: @"\\n" withString: @"\n"];
}
[composeViewController setBody:body];
}
[composeViewController setBody:body];
}

NSMutableArray* recipients = [command.arguments objectAtIndex:0];
if (recipients != nil) {
if ([recipients.firstObject isEqual: @""]) {
[recipients replaceObjectAtIndex:0 withObject:@"?"];
NSMutableArray* recipients = [command.arguments objectAtIndex:0];
if (recipients != nil) {
if ([recipients.firstObject isEqual: @""]) {
[recipients replaceObjectAtIndex:0 withObject:@"?"];
}

[composeViewController setRecipients:recipients];
}

[composeViewController setRecipients:recipients];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.viewController presentViewController:composeViewController animated:YES completion:nil];
});
}];
Expand Down