When installed on iOS and Android phones, the Google Maps application registers to handle links of the form "https://goo.gl/maps/linkHash" (iOS Universal Linking or Android Deep Linking). These links directly open in the application if it is loaded, but in the mobile browser if it is not. They are perfect for messaging.
We can generate full links to maps easily (https://maps.google.com/?q=somequery), and we can shorten those links using Google's URL Shortener. Unfortunately, the result is a link of the form "https://goo.gl/linkHash" (no maps directory), and this form does not trigger the link to Google Maps in iOS and Android; they always open in the mobile browser or two-step through to the app.
I have not been able to find a documented and long-term-supported way to programmatically generate the shortened "https://goo.gl/maps/linkHash" URL. A method does not seem to be published in either the mapping APIs or shortener API.
I have found that it is simple to make the same call to https://www.google.com/maps/preview/shorturl that maps itself makes when generating a shareable short link. This creates the correct form URL for universal/deep linking, but again, I have not been able to find examples of this API in general use or in docs.
Does anyone have info on the official (proper) way to generate this form of link programmatically server side (not manually, in browser, or using a client lib)?
Hoping to use these shortened forms for messaging with a bit more confidence, and I'm hoping I've just missed something obvious. Thanks for any suggestions!