Save mail attachment into Third-party app's sandbox

Is this permitted / possible to save mail attachemtn into third-party sandbox?

If it is permitted, would you please give me some reference to do that?

Accepted Reply

My question is how to set it replace old one, but not keep all.

Once your app has been passed the document in this way, it’s your app’s responsibility to manage it. If you want to move it out of that directory, or simply delete it, that’s fine.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Save mail attachment into Third-party app's sandbox

What platform are you targeting?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your reply.
It is under ios.

iOS’s sandbox makes this tricky; it’s not possible to directly modify another app’s sandbox.

Can you explain more about this workflow? Where are these attachments coming from? And what other app’s do you want to pass them to?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo,


I want to save a p12 file from email attached file into application's sandbox, and read p12 file to extract them to do internet authentication.

I think I can download p12 file from some server but there is no such support for this application, so ask your help to check if I can save email attached file directly into applicaiton's sandbox.


Thanks.

Thanks for the explanation. I’ve looked at this issue before, but a long time ago and things might have changed since. The basic strategy here is to have the target app support

.p12
as a document type. The user can then open in that document in your app using Mail’s standard ‘open in’ UI.

The gotcha that I encountered back in the day was that Mail hard coded the handling of

.p12
files, so it wouldn’t offer them to your app. The workaround was to use a different extension, one unique to your app. I’m not sure if that’s still necessary today.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

It is very helpful.

Actually followin your message, I can save them into third-party app by adding Document types and Exported Type UTIs into info.plist.

But there is another issue, which function will be called when file is saved in, I think I should find that from AppDelegate, but unfortunately, I don't find the exactly one.


Can you give some guides which is the function is exactly called when saved into sandbox?


Thanks.

If it’s coming in through the document architecture, you should get a

-application:openURL:options:
call.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Yes, you are right.

Following this one, I found that every time I opened the file from mail attached file, it will save data automatically into path Document/Inbox, and it will not replace old one but keep all.

My question is how to set it replace old one, but not keep all.


I try to use this call (application:openURL:options:) to delete old one, then insert new one, but I found that it is always insert file first then do the code in this call (application:openURL:options:), and return value of true or false will not impact anything, it is alway inserted.


Thanks for your help.

My question is how to set it replace old one, but not keep all.

Once your app has been passed the document in this way, it’s your app’s responsibility to manage it. If you want to move it out of that directory, or simply delete it, that’s fine.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

eskimo,


Many thanks for your response. I have followed your suggested to handle it.

Have a nice day.