2

Our organization uses an enterprise account and the itms-services protocol to internally deploy apps over-the-air. Our plists and ipas are hosted on Amazon S3 and everything works as expected - you click a link and an alert pops up asking if you'd like to install the app. We are now trying to store our files on Firebase storage and send out links in the following format:

itms-services://?action=download-manifest&url=https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/MyApp.plist?alt=media&token=my-token

Pasting this link in Safari opens a dialog asking: 'Open this page in "iTunes"?' Clicking on open does nothing. It's worth mentioning that if I upload the same plist/ipa combo to S3 it works fine. Also, if I paste the url itself (without the itms-services part) I am able to download both plist and ipa.

Why don't I get the dialog asking if I'd like to install the app? I have a feeling that it's somehow related to an issue with permissions to Firebase but as I am able to download the file directly I'm not really sure.

Gad
  • 2,867
  • 25
  • 35
  • I'm running into the same issue. Did you ever solve this? – Gabriel Garrett Dec 24 '18 at 04:28
  • 1
    @zavtra I'm sorry to say that I didn't. In the end we were instructed to use S3 so I never got around to figuring this one out... If you do find a solution, please post it here as it might be helpful for others. – Gad Dec 24 '18 at 08:05

2 Answers2

2

gfvilela's solution worked in 2017 and if you have spaces you still need to do that but there is a new issue where firebase removes the // after itms-services: in redirects.

I used https://www.redirect-checker.org/index.php to check what my redirect actually redirects to and it shows that it's leaving out the //:

itms-services:?action=download-manifest&url=...

Somehow this still opens the popup "Open this page in Itunes" but it will not open the next popup "<domain> would like to install <app>" probably because the Itunes process that is opened parses the URL different from how iOS handles deeplinks.

I can only speculate but I think the problem with firebase removing the // lies with how they handle : since they use it with their "glob" pattern matching: https://firebase.google.com/docs/hosting/full-config.

Attempts

  • I tried encoding the entire URL, just the // part and even only the : but all of these redirect to mydomain.com/itms-services....

  • I tried using the Dynamic Links module but that doesn't support this either:

    Please enter a valid URL starting with http:// or https://

Solution

I think the only way to do this using firebase is to redirect using functions similar to this question: Cloud function for firebase to redirect to a URL

This is definitely more work and is not included in the free firebase package but here is how I solved it:

  1. run firebase init functions

  2. Write the redirect in functions/index.js

exports.downloadApp = functions.https.onRequest((req, res) => {
  res.redirect(302, 'itms-services://?action=download-manifest&url=<YOURMANIFEST>');
});
  1. Run firebase deploy --only functions

  2. In your firebase.json add a rewrite (not redirect) to the function:

"rewrites": [
  {
    "source": "/app",
    "function": "downloadApp"
  }
]
  1. Run firebase deploy --only hosting

Note

This is an awful lot of workaround just because firebase doesn't have an escape character for : for when you don't want to use it for "glob" pattern matching.

Casper Zandbergen
  • 3,419
  • 2
  • 25
  • 49
  • According to https://golang.org/pkg/net/url/#URL, a URL should be of the form `[scheme:][//[userinfo@]host][/]path[?query][#fragment]`. Unfortunately, since itms-services doesn't include a user, host, or path, that means that it doesn't get the `//` from that section of the uri. We're working on a fix for this. – Kiana Apr 17 '21 at 00:05
  • @Kiana That definition page says you can do "host or host:port" but ports also don't work on firebase and need the exact same workaround as I described in this answer. – Casper Zandbergen Apr 18 '21 at 10:05
  • Do you mind filing a feature request for allowing ports in redirects? I don’t see any reason why we can’t support those. (It’s not the globs that are causing issues) https://firebase.google.com/support/troubleshooter/report/features – Kiana Apr 19 '21 at 16:52
  • @Kiana I already made a support ticket (case 00084631) for this in september last year. In which support replied to me that globs were the issue. x) They said there were plans to support this in the future but didn't give a timeline. – Casper Zandbergen Apr 20 '21 at 16:00
1

Your url should be encoded.

For example:

Normal url: https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/MyApp.plist?alt=media&token=my-token

Encoded url: https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fmy-app.appspot.com%2Fo%2FMyApp.plist%3Falt%3Dmedia%26token%3Dmy-token

Finally: itms-services://?action=download-manifest&url=https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fmy-app.appspot.com%2Fo%2FMyApp.plist%3Falt%3Dmedia%26token%3Dmy-token

jsheeran
  • 2,912
  • 2
  • 17
  • 32
gfvilela
  • 11
  • 2