Skip to content

Commit

Permalink
Merge pull request #219 from maihannijat/patch-1
Browse files Browse the repository at this point in the history
Update Sms.m - Fixes the main thread issue (dispatch_async)
  • Loading branch information
dbaq authored Feb 17, 2021
2 parents 77e8591 + 1e81fd7 commit 49a4b45
Showing 1 changed file with 17 additions and 17 deletions.
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

0 comments on commit 49a4b45

Please sign in to comment.