CKSMSComposeRemoteViewController is dedicated to waiting for the fence barrier from com.apple.mobilesms.compose

Ok, so sendSMS worked fine on ios7 and below. However, on ios8, the sendSMS function simply fails with an error in the question header. I get a warning here (after trying to solve by changing NSArray to NSString using other questions): Incompatible pointer types assigning "NSArray *" from "NSString *" to controller.recipients = recipients; It returns the result of MessageComposeResultCancelled.

if (ABMultiValueGetCount(phoneNumbers) > 0) { phone = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, 0); [self sendSMS:@"Play me on PokerBuddies. Download the app at: https://itunes.apple.com/us/app /poker-buddies/id404168013?mt=8" recipientList:[NSString stringWithFormat:phone, nil]]; } else { phone = @"[None]"; } - (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSString *)recipients{ MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; if([MFMessageComposeViewController canSendText]){ controller.body = bodyOfMessage; controller.recipients = recipients; controller.messageComposeDelegate = self; [self presentViewController:controller animated:YES completion:nil]; NSLog(@"Send SMS"); } } 
+5
source share
1 answer

I have the same issue as the MessageComposeController mailing issue. I solved it by doing this.

You need to create an instance variable of MFMessageComposeViewController, and when you are going to present a message controller, you need to check if the instance object has already been created, then do it nil and initialize this object again. Thus, the "CKSMSComposeRemoteViewController" is confined to waiting for the fence barrier from com.apple.mobilesms.compose "will not come, and the controller will open for sure.

 if ([MFMessageComposeViewController canSendText]) { if (messageComposer) { messageComposer = nil; messageComposer = [[MFMessageComposeViewController alloc]init]; } messageComposer.recipients = arrPhoneNumber; messageComposer.messageComposeDelegate = self; messageComposer.body = @"Your text"; isMessageComposeAppear = 1; [self presentViewController:messageComposer animated:YES completion:nil]; } 
-1
source

Source: https://habr.com/ru/post/1206630/


All Articles