MFMailComposeViewController is buggy on iOS 14 - ios

I recently found out that MFMailComposeViewController behaves buggy when entering the recipient email, it causes a loop going in the view as shown in the GIF below: Bug
My implementation of MFMailComposeViewController is pretty standard:
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setSubject("Report an issue")
mail.setMessageBody("", isHTML: true)
present(mail, animated: true)
} else {
}
I have not been able to replicate this on iOS 14.6 but other users were able to replicate this behavior. They have iOS 14.3 and 14.4 on iPhone X. I think it has something to do with the iOS version or the specific iPhone model.
Is there any way I can use the simulator to debug MFMailComposeViewController functionality? Even removing canSendMail(), I can't seem to make it works with the simulator.

Related

MFMailComposeViewController behaves differently in iOS 13 simulator and device

I'm trying to display MFMailComposeViewController in an app.
if MFMailComposeViewController.canSendMail() {
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.navigationBar.tintColor = .white
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setToRecipients(["support#gmail.com"])
mailComposeViewController.setSubject("Feedback")
present(mailComposeViewController, animated: true)
} else {
print("This device is not configured to send email. Please set up an email account.")
}
In iOS 12, it shows up without an issue. In both simulator and device.
But when I run the same project on a device running iOS 13, it looks like this.
The navigation bar color is gone. Also the send button is also invisible.
So I added mailComposeViewController.navigationBar.backgroundColor = .mv_primary but it still doesn't show on the device. Strangely the background color shows in the simulator.
However there's a strange behavior. The MFMailComposeViewController immediately dismisses by itself when I run it in the simulator.
The following error also shows up in the Xcode console.
[Common] [FBSSystemService][0x5f27] Error handling open request for
com.apple.MailCompositionService: {
userInfo = {
FBSOpenApplicationRequestID = 0x5f27;
}
underlyingError = ; } 2019-11-01
14:40:05.214158+0530 MailCompose[11289:262267] [Assert] Connection
request invalidated without resuming our _serviceSessionConnection.
This is an error. 2019-11-01 14:40:05.216901+0530
MailCompose[11289:262054] [General] #CompositionServices
_serviceViewControllerReady: NSError Domain=_UIViewServiceInterfaceErrorDomain Code=0
I guess the weird dismiss error is a Xcode bug. But how do I fix the background color and the send button not showing up in the device?
This is how I set all the navigationbar related styles.
UINavigationBar.appearance().barTintColor = .mv_primary
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
}
Demo project
Add this line of code before present it. It will work normal. This a change in iOS 13
mailController.modalPresentationStyle = .fullScreen
The reason why the Mail composer dismisses immediately is because you can't actually send an email from the simulator. The implementation is different from iOS itself.
What I guess is happening here is that while the simulator implementation uses just some normal UI elements, the MFMailComposeViewController on native iOS is actually hosted like UIDocumentPickerViewController or UIActivityViewController. This means screenshots and trying to traverse the view tree is impossible, because the view is not an actual part of your application. They do that because these controllers contain user private information. Hosted view controller do NOT allow for customization, and do not comply with your global UINavigationBar.appearance(). This would explain why it does show up in the simulator and not on your native device.
This is new UI Style from iOS 13. You can disable it in Storyboard or set manual.
Presenting modal in iOS 13 fullscreen

IOS13 CNMutableContact Bug [duplicate]

This question already has answers here:
Keyboard overlaying action sheet in iOS 13.1 on CNContactViewController
(7 answers)
Closed 3 years ago.
I just try to call function with below code
func bugVersionPressed() {
let contact = CNMutableContact()
contact.familyName = "aaaa"
contact.givenName = "aaaa"
contact.organizationName = "bbbb"
let addContactVC = CNContactViewController(forNewContact: contact)
let navController = UINavigationController(rootViewController: addContactVC)
navController.view.backgroundColor = .red
navController.modalPresentationStyle = .fullScreen
self.present(navController, animated: true, completion: nil)
}
But the apple seems havent handle keyboard dismiss problem, I CAN'T DISMISS THE KEYBOARD AND I CAN'T GO BACK TO THE HOME PAGE BY PRESS "Cancel"
PIC1 : (Before present to CNContactViewController)
PIC2 : (Bug Case, Keyboard Cannot dismiss)
PIC3 : (Wish Case, Keyboard Dismiss while Clicked "Cancel")
In case I found a AppleStore App https://apps.apple.com/cn/app/%E5%BE%AE%E5%95%86%E5%8A%A0%E7%B2%89%E5%AE%9D-%E5%85%8D%E6%B3%A8%E5%86%8C%E6%B7%BB%E5%8A%A0%E6%B4%BB%E7%B2%89-%E8%81%94%E7%B3%BB%E4%BA%BA%E5%A5%BD%E5%8F%8B%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90/id475661774 but same problem. Please tell me what can I do. Many thanks.
The problem doesn't occur in iOS 13, but in iOS 13.1.
I think this is a problem with the CNContactViewController, not CNMutableContact.
I'm sorry, but I don't know how to avoid it because of Apple's framework.
Send a bug report to Apple.

UIDocumentPicker can not display Browse at iOS 11

I wrote a program of UIDocumentPicker.
However, if I tap "Browse" on the iOS 11 simulator, loading continues to be displayed and could not be displayed.
What kind of response is necessary?
Development environment
Xcode: Version 9.0 beta 5
Simulator: iPhone 7 Plus (iOS 11.0)
Error Image
Code
https://github.com/amarron1/SampleDocumentPicker
class ViewController: UIViewController, UIDocumentPickerDelegate {
let UTIs:[String] = ["public.data"]
// Save to this application from iCloud
#IBAction func importDocumentPicker(_ sender: Any) {
let importPicker = UIDocumentPickerViewController(documentTypes: self.UTIs, in: .import)
importPicker.delegate = self
present(importPicker, animated: true, completion: nil)
}
}
Log
2017-09-06 11:37:54.790680+0900 SampleDocumentPicker[40282:5448334] Unbalanced calls to begin/end appearance transitions for <_UIWaitingForRemoteViewContainerViewController: 0x7fb54c6153b0>.
2017-09-06 11:38:04.101520+0900 SampleDocumentPicker[40282:5448334] [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
By the looks of it, this is a simulator-only issue. (iOS 11.0 simulator)
UIDocumentPicker works ok on devices.
If anyone encounters this problem, just test on a real device.

MPMediaPickerController shows an empty screen on iOS10

I am trying to port my apps to iOS 10, including the visualization of a MPMediaPickerController by means of the following code:
#IBAction func handleBrowserTapped(_ sender: AnyObject){
let pickerController = MPMediaPickerController(mediaTypes: .music)
pickerController.prompt = NSLocalizedString("Add pieces to queue", comment:"");
pickerController.allowsPickingMultipleItems=true;
pickerController.delegate=MPMusicPlayerControllerSingleton.sharedController();
self.present(pickerController, animated:true, completion:{
MPMusicPlayerControllerSingleton.sharedController().storeQueue()
})
}
Yet all that appears on the screen is a full white screen with no back buttons or other, differently from the previous iOS versions. The block is called and so the picker's presentation seems to succeed. What could be the problem?
Add Key-value to Plist :
<key>NSAppleMusicUsageDescription</key>
<string>$(app Name) uses music</string>
The issue was fixed by the latest beta now asking for an authorisation to access the iTunes library.

Sending sms swift in simulator [duplicate]

This question already has an answer here:
Difficulty obtaining capability to SMS via MFMessageComposeViewController in the iPhone simulator
(1 answer)
Closed 7 years ago.
If it possible to simulate sending sms in iPhone Simulator. I am not expecting to really send sms, just to show sms sending panel.
This is my code:
if MFMessageComposeViewController.canSendText() {
let messageVC = MFMessageComposeViewController()
messageVC.messageComposeDelegate = self
messageVC.recipients = ["1111111111", "2222222222"]
messageVC.body = "hello phone"
self.presentViewController(messageVC, animated: true, completion: nil)
} else {
print("Not using messages")
It always just print "Not using messages". Can someone advice, am I doing something wrong?
Thanks!
No it is not possible to show sms sending panel in iOS simulator. You'll have to register for Apple's developer program and test that on the device.

Resources