I’m building an app that allows the user to export en import data files and send them by e-mail.
So I’ve created a data file type with extension “.myAppExtension”.
At first time everythings goes well. I can’t export and send an e-mail. And when I open the e-mail, the method does work.
-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if (url != nil && [url isFileURL]) {
NSLog(@"%@",url);
NSLog(@"%@",[url pathExtension]);
if([[[url pathExtension] lowercaseString] isEqualToString:[@"myAppExtension" lowercaseString]]){
//Deal with received file
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Export ok" message:[NSString stringWithFormat:@"This file has been added : %@",[url lastPathComponent]] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil,nil];
[alert show];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Export failed" message:[NSString stringWithFormat:@"This extention is not supported : %@",[url pathExtension]] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil,nil];
[alert show];
}
}
return YES;
}
My issue is that when I want to export an other type of file with extension “otherExtension”. I did not create data type for this extension in my app.
So I export and send an e-mail with this second type of file. The file name showed in e-mail “file.otherExtension”. But, this is the issue, when I tap this mail attachement the e-mail app offers me to open it in my application. That’s not what I want and, as I said, I did not create the data type for “otherExtension”.
Edit : This is how I created the file type in myApp-info.plist :

If someone is interested, the issue were from the send e-mail fonction.
By adding the mime type to mail attachment the receiving application was using it to read the file. Replacing the mime type by “nil” solved my issue.