Friday, September 7, 2012

iPhone - Sooo, what's your "There's a problem" email content?

Dedicated to all those who want a user complaint to re-incarnate as an email and not as a one star review on the AppStore. Here is my take on the "submit an issue" email body:

 NSString *emailBody = [NSString stringWithFormat:@"%@%@\r\n
iOS Version:%@\r\nDevice:%@\r\n
OS language:%@\r\n
Reginal settings:%@\r\n
App: %@", 
NSLocalizedString(@"Description of the problem:",nil), @"\r\n\r\n\r\n",  
               [[UIDevice currentDevice] systemVersion],  
               [[UIDevice currentDevice] platform],  
               [[NSLocale preferredLanguages] objectAtIndex:0],  
               [[NSLocale currentLocale] localeIdentifier],  
               [[NSProcessInfo processInfo] processName]  
               ];  
   [picker setMessageBody:emailBody isHTML:NO];  

Which results in the following (for iPhone 4S):

The only out of standard APIs part is that  [[UIDevice currentDevice] platform]
That would be something like:

.h

 #import <UIKit/UIKit.h>  
 @interface UIDevice (Hardware)  
 - (NSString *) platform;  
 @end  

.m

 /* Thanks to Emanuele Vulcano, Kevin Ballard/Eridius, Ryandjohnson */  
 /*  
  - Bluetooth? Screen pixels? Dot pitch? Accelerometer? GPS disabled in Egypt (and others?). - @halm  
 */  
 #import "UIDevice-hardware.h"  
 #include <sys/types.h>  
 #include <sys/sysctl.h>  
 @implementation UIDevice (Hardware)  
 - (NSString *) platform  
 {  
     size_t size;  
   sysctlbyname("hw.machine", NULL, &size, NULL, 0);  
   char *machine = malloc(size);  
     sysctlbyname("hw.machine", machine, &size, NULL, 0);  
     NSString *platform = [NSString stringWithCString:machine encoding: NSUTF8StringEncoding];  
     free(machine);  
     return platform;  
 }  
 @end  

All the credit for that [platform] thing goes to Erica Sadun and guys in the .m comments.

And this is it!!!

Do you add more to your "submit an issue" email? Please share in comments then!

Post a Comment