If you use TestFlight to send Beta Feedback, it automatically attaches a file called device_information.txt
and this includes some basic information about the device.
I want to make a support button in my app, and I'm using MFMailComposeViewController
to create a new email. How can I retrieve (or create) the device_information.txt
file, and then attach it to a new email?
This is an example of what the device_information.txt
file would contain:
App Information:
App Name: [App Name Here]
App Version: 1.0
Installed App Version: 1.0
Device Information:
Device: iPhone6,2
iOS Version: 12.1.2
Language: en-AU (English)
Carrier: [Carrier Here]
Timezone: [Timezone Here]
Architecture: N/A
Connection Status: Cellular data
Paired Apple Watch: N/A
How does TestFlight achieve this? It must be possible, so if anyone can guide me in the right direction I'd really appreciate it.
You can find most of this information in UIDevice class https://developer.apple.com/documentation/uikit/uidevice
You can than append the needed information to the mail text like this :
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setMessageBody:"your message here" isHTML:NO];
or using attachment like this:
[controller addAttachmentData:data mimeType:@"text/plain" fileName:@"test.txt"];
in Swift:
let controller = MFMailComposeViewController()
controller.mailComposeDelegate = self
controller.setMessageBody("My message", isHTML:false)
controller.addAttachmentData(data as Data, mimeType: "text/plain", fileName: "test.txt")