Sending a file from email to my iOS application

I’m sure this has been answered 1,000 times, but I can’t find it.

Before I asked how to send a file (share) from my iOS app, and got an answer that there are declares to allow me to send it via email - really just opens it in Mail and the user has to hit send, which is a-ok.

Now that someone gets the file, how can they tap on it and have my iOS app be a possible recipient.

I realize I can setup a server to share things through, but would really like to share via messaging or email if possible.

Suggestions?

PS: If I’m really just thinking about this from the wrong paradigm, let me know a more appropriate approach.

TIA

an email address doesn’t “belong” to a device or to a particular “app”… a device can be configured to recieve email from one (or many) email addresses… and an app can be configured to use one of the email addresses configured on the same device

So the user only has the ability to reply to the email they got, but they have no control over what device (if any) will recieve it.

So this isn’t supported by Xojo, or any hacked workarounds which I tried. First you will need to register the file type you want your app to be able to open. Then you need to use either the ‘application:didFinishLaunchingWithOptions:’ or ‘application:openURL:options:’ events. I’ve tried to hook into these with hacks, and it hasn’t worked. Maybe @Joe Ranieri or @Norman Palardy can provide you with a workaround, but there has been no love for iOS for several years now and no progress was ever made on my feature request <https://xojo.com/issue/41984> from 2015. This is such a basic event that missing it kills many possible app ideas. Its a shame that Xojo didn’t support it from the beginning since it is so fundamental to iOS development and can’t be added via hacks like some of the other events.

Ok… either I am confused about what the OP wants, or I’m confused about what Jason is saying…

I thought the OP was asking for the ability to have his app send an email (easy enough), and then have the recipient of that email reply directly to his app. That is not possible. What is possible is for the recipient to send an email reply to an email registered on the device (as I explained above). And then what would be required is for the app to do two things

  • be notified that an email was received (and that that email is relevant to the app (it could be an email from anyone)
  • have the app extend beyond its sand-box and read the email. which surprising is allowed by Apple

Step #1 could be achieved by having the app scan the entire mailbox and cherry pick as required.

So I guess in a round-about convoluted way, it kinda sorta is possible

I may have misunderstood as well. I thought he wanted to be able to open the attachment in mail on another phone and then click share and open in his app. The instructions I gave are to do that for an XCODE app, as it cannot be done in Xojo at this time. If he wants to read through the user’s email then maybe that can be done, but I have no experience doing that and a quick google search indicates you would have to use a google gmail framework which isn’t going to be easy in Xojo (if it’s even possible, that depends on what Google gives you binary-wise).

Edit: Share wouldn’t be directly required, it would make the ‘Open in MYAPP’ appear in the document preview.

there are iOS frameworks that can read the inbox of the client email app on an iPhone/iPad, how/if Xojo can get to them is another question. Its possible to send an email directly without need of the Share Panel as well… but the same question as to if Xojo can deal with the simple code requirements involved.

@Chris Halford if you want this to work you will probably need to setup a custom server and then setup a remote notification service on it that talks to your app. That is possible with some of the hacked together declares I have. Alternatively you could have the app poll for updated documents they would receive when the user opens the app, but then they won’t get notifications and may miss something if it is time sensitive.

Bottom line:

  1. It’s not currently possible in Xojo to have your app properly open documents from Mail/Gmail or another email app (see my earlier comment)
  2. Setting up your own server is (somehow :frowning: ) the easiest option. Once you have done this you can
    • a. Use the easy approach of polling for new documents
    • b. Setup remote notifications with some work so the user is notified when a new document has arrived

Let me know if you have questions about setting up notifications if you decide to pursue that route.

OK… here’s the deal:

  1. my app makes a file that is proprietary to MY iOS app… in my case, I’m written an application that creates pacing strategies for races (marathons and such)
  2. I want to share it with someone else (yo, beware of the hills at mile 6… they will kill your pace, so try what I did to make up for it in the last 3/4rd mile)
  3. I don’t want to use a server, I’d like to send it via email or SMS. It means I don’t have to do the whole song and dance with connecting people, accepting/rejecting “friend” requests and tracking them.

I have a ton of apps that I can do this with, so I was hoping a Xojo created app could too.

Based on your responses, I don’t think I can do this, so I’ll figure out some mechanism of sharing via a server.
@Jason King, I will surely be asking about notifications. Thanks for the thoughtful responses.

I guess what I’ll do is save it on a server and allow the notification that it’s waiting to be sent via SMS or other. Like post for the world to see, but only tell whom you want where it is. Can a custom URL be directed to my Xojo app to open?

Is there a way to get a unique name, like your Apple ID, from within a Xojo app?

Thanks guys.

Ok… that is NOT what I got from your post…
what I read was

  • Your app SENDS an email … (yo… beware etc…)
  • Who ever GETS that email, responds with more information
  • Your app RECIEVES that new data, and somehow processes it…

If all you want/need is to SEND the email… THAT is easily done… It is step #3 that is difficult

I.E. you app CREATES/SENDS an email, and does not need to consume any incoming data?

Dave, it’s a bit more (maybe less… .different) than that. I want to send a file in an email (I’m aware I can do that). But then when I get that file, I want to tap it, and have it opened in the same app on “my friend’s” iPhone.

Sorry… I’m aware I’m doing a horrendous job of explaining this.

Horrible analogy: I make a layered image file on my Xojo built iOs app. I send it to you. you get it in your email, and import it into your copy of my iOs app, and then read it… modify it… whatever you might do.

hope this is more clear. Sorry!

[quote=387779:@Chris Halford]I guess what I’ll do is save it on a server and allow the notification that it’s waiting to be sent via SMS or other. Like post for the world to see, but only tell whom you want where it is. Can a custom URL be directed to my Xojo app to open?

Is there a way to get a unique name, like your Apple ID, from within a Xojo app?

[/quote]
So I did a little more digging. The same function is used for opening URLs as accepting files since files are represented by URLs in the filesystem.

If you decide to send text messages, instead of using the built in notification system, you can fake it by having a custom scheme registered and just using it to launch your app (since it will open regardless, you just won’t get the data because of the aforementioned short comings). Then you can poll for the updated information from your server when the app launches. The issue is then you have to collect phone numbers and have your server know about the recipient’s number to send them the message.

Using notifications has a similar issue but you are given an ID which uniquely identifies the app when doing notifications. There aren’t other identifiers you can use, they have all been removed by apple in the last couple years.

If you want to add custom link support so a text message could have a clickable link which launches your app you’ll need to follow this link:
https://developer.apple.com/documentation/uikit/core_app/communicating_with_other_apps_using_custom_urls?language=objc

PS. If you do go the text message way you will need to pay for a service to send texts

I need to digest these options for a bit - and consider the best approach vs the complexity of having my server track users and for it to manage that complexity. There is just someone sexy about sending the file via SMS that would really work for this scenario.

Thank you for the information.
This has been VERY informative.

You’re welcome. Feel free to ask if you have more questions and I’ll do my best to answer