I am trying setup iOS universal link with a private server. I put my apple-app-site-association on my private_domain/apple-app-site-association .
However, iOS can not download the Apple-app-site-association from server even testing device in the same network as my private domain . I am wondering if it possible to set up Universal Link with Private Domain ? Thanks
This is not possible, no. You'll see in the device logs, if you watch during app installation, that setup of universal links is failing because the domain cannot be reached.
You can work around this by creating a public domain (just use an Azure site or something similar). The apple-app-site-association must exist as a static file. Note that if you are using Azure you'll need to add a file handler for the empty file extension and another file handler for Android's json file extension if you're doing Android as well.
If you want the links to work for web as well then just have the paths redirect to your internal (private) domain.
Related
Project workspace
Mobile Project: ReactNative 0.64.3 / Expo with Managed Workflow / IOS 14.6 / NPM
Sharing Library: ReactNative's default Share library.
Website/Domain: Statically hosted via S3, single page app built with TS/Gatsby. Caching handled with CloudFront.
Synopsis: I'm using universal links and query params to allow my users to share tickets. The Universal links are being stripped of all route params and query strings when the link is shared by the native sharing dialog. Using the COPY/PASTE function in the native sharing dialog always copies a complete link, which can be pasted anywhere and used successfully to open the app. The EMAIL option also works, opening Mail with the correct url string and autofilled as expected. The problem arrises when I try to share the link via iMessage. I'm running the project on an iPhone as a fully deployed Apple Testflight standalone app.
The app does download the AASA file on app install, which is statically hosted via an S3 bucket. I have verified its availability via postman and the online AASA validator here https://branch.io/resources/aasa-validator/
The app always opens when opening a valid universal link, such as when I manually type it into iMessage or other sharing medium -- email, etc. Because of this, I'm inclined to believe I have a problem with where the link string is being generated rather than the AASA system.
const ticketShare = (ticket: Ticket) => {
const link = Linking.createURL("www.sample.com/share_ticket", { //Expo Linking library
scheme: "https",
queryParams: {
...ticket
}
}).replaceAll("%25", "%"); //double encoding problem I have yet to properly fix.
console.log("link: ", link); //always the correct url here.
Share.share({ url: link }); // request to open the native sharing dialog activity. ('url' for ios)
};
Correct url is something like:
https://www.sample.com/share_ticket?my=query¶ms=here
Stripped url is something like:
https://www.sample.com/
sharing dialog image.
https://www.sketchappsources.com/resources/source-image/simple-share-actionsheet-ios-13-hugo.png
"COPY" actions always copy the correct url, "MAIL" works as well.
Using "MESSAGE" or any of the "recent" actions in the top row fails, sharing the base url only.
The title and website abbreviation at the top of the action sheet do render properly, pulling metadata/images from the website.
To make it more complicated, the share function does yield the correct url directly after a fresh install, but then never again. Console.logs always log the correct url.
I have tried react-native-share's library with the same results. (Wraps the same native bridge code?)
I have checked the react-native github page for issues related to this with no result. I have combed StackOverflow for a few days without results. Usually that means its something simple.. here's to hoping.
Anyone out there run into this issue? Thanks!
I'm trying to register a custom protocol with electron. I want it to be a redirect location that a website can use to provide an api key (like myprotocol://example/payload=api-key). I have been using electron's registerHttpProtocol and also tried electron's interceptHttpProtocol.
But, when the website tries to redirect to my protocol my electron app doesn't do anything. The website goes to myprotocol://example/payload=api-key, and registers a "page doesn't exist error"--while nothing happens in my app.
This is in a development environment. I've seen some discussion about custom protocols that assume a production environment.
Can you register a custom protocol with electron in development?
Why am I not able to intercept the website's going to the protocol I've set out?
Here's my code:
main.js:
app.whenReady().then(() => {
protocol.registerHttpProtocol('examplep', (request, callback) => {
console.log("examplep", request);
callback('it-worked');
}, (error) => {
if (error) console.error('Failed to register protocol = ' + error)
})
protocol.interceptHttpProtocol("examplep", function (request, callback) { //I've tried both registerHttp... and interceptHttp... methods, so including both here; though I think in practice only one should be required
console.log('intercepted!' + request)
callback(request);
});
})
redirect url provided to website:
'http://examplep'
And I've whitelisted this url on the website itself.
I've also tried related methods registerStringProtocol, interceptStringProtocol, registerFileProtocol, and interceptFileProtocol, without success.
What am I missing?
Sounds like you need to support deep linking fora desktop app, which is done via a Custom URI Scheme and is registered with setAsDefaultProtocolClient.
When your Electron app starts up write this code to register the scheme, on the main side of your app:
const customScheme = 'x-mycompany-myapp';
app.setAsDefaultProtocolClient(customScheme);
The custom scheme can be tested from the command line like this, depending whether you are running macOS or Windows:
open x-mycompany-myapp:/some/location
start x-mycompany-myapp:/some/location
A web client will just invoke a URL as in this Javascript code of mine;
The notification will be received within the main side of your app and on Windows will attempt to create a new instance of the app, in which case you need to detect this condition, process the notification then cancel the new app instance.
On MacOS it will be received within the open-url event, so you register it like this:
app.on('open-url', this._onOpenUrl);
Once the main side of the Electron app has the notification, it needs to get the URL information and forward it to the renderer process. You can use ipcMain events for this.
Finally the code for receiving the notification in running instances and starting the app from a deep link are different.
EXAMPLE APP
Since the code is a little tricky, here is some example code that may be useful, to give you something to compare against. If it helps you can also run the app by following the instructions in the blog post:
Code
Blog Post
My use case is around receiving OAuth responses after signing in from the system browser. Hopefully you can borrow some ideas from it related to deep linking though.
INFO.PLIST
My understand is that in a development environment (on macOS) deep links work when the app is running, but if you stop the app and attempt a deep link it will not start the app.
You can only resolve this for a packaged app, which requires an info.plist. In my code sample the info.plist is generated from build protocol entries in the package.json file.
My code sample is packaged in a basic way by the Electron Packager, so when I run npm run pack, the app is built to a dist folder. I can then run the packaged version of the app and it gets registered with the system - as can be seen in the Default Apps tool. See screenshots in the blog post.
SECRETS
Secrets for a desktop app should be stored using operating system secure storage. There are screenshots of credential storage in the blog post.
On Electron, have a look at the keytar component - and this wrapper class of mine. I am storing tokens (strings) so you should be able to adapt the code for your API keys.
How can I add deeplink (url like https://www.example.com) in iOS using swift.
The scheme in plist is not working if I enter url in it.
You can check the screenshot of plist attached.
You are attempting to register your app for the URI scheme https which Apple has already reserved for Safari, therefore you will not be able to use it.
Option 1: Custom URI Scheme
You must come up with a custom URI scheme like customURI://www.domain.com
Downside: If a user clicks on this link without the app installed. iOS will show that user and error.
Option 2:Universal Links
Apple launched Universal Links in iOS 9 to enable developers to associate their http link with their app. This requires you to host your own AASA file on your domain so that your domain becomes associated with your app ID.
Option 3: Branch.io
Branch will actually bundle up Universal Links and URI schemes and use them appropriately when necessary. They also perform deferred deep linking. They'll host your AASA file for you, but your app domain will have to be either https://*.app.link or some dedicated subdomain of a domain that you own.
only to be precise:
If you need more docs about in Apple docs, use the CORRECT name for the technology.
If You use url starting with a schema different from http (for example fb:// for FB) is not a LINK, is a "custom" url.
Anyway use: custom url and see at:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
I've set up Universal Links on my iOS app using an aliased subdomain of my backend with a scheme like sudomain.mydomain.com. I want users that DON'T have the app installed to be redirected to our page in the App Store rather than hitting some nonexistent endpoint on our server (we don't have a webapp only a mobile backend).
I was thinking about doing something like this:
app.get('*', (request, response) => {
const domain = request.headers.host,
subdomain = domain.split('.');
if ( subdomain[0] === 'subdomain'){
response.redirect('www.linktoappstore.com');
}
...
});
However I don't want this to interfere with Universal Linking for people who DO have the app installed. Are Universal Link get requests sent to my server or does iOS intercept them before that happens?
This should work just fine.
When Universal Links are configured and your app is installed, the device does NOT hit the server before launching the app. This is because iOS caches the apple-app-site-association file when the app is initially installed, and if the URL being opened matches a path defined there, Universal Links kick in. In that situation, iOS completely bypasses any web request and immediately launches your app.
Of course, this means you can't track Universal Link traffic, which can become a major pain point. To work around this, you need something like Branch.io (full disclosure: I'm on the Branch team) to fill in the missing data.
Separately, if you're proxying the subdomain, make sure iOS doesn't see that as any sort of redirect. Otherwise the apple-app-site-association file won't be scraped at all (common Universal Link implementation issue).
Is it possible for a web app to make use of the box:// url-scheme with parameters to open a specific file in the Box iOS app?
The Android Box app has a similar function with its intent links.
And if it is possible, what would these parameters be? (already using Oauth2 API to list files with shared links).
boxopendirect://file?id=<fileid> to redirect to a file.
boxopendirect://folder?id=<folderid> to redirect to a folder
It certainly is possible to open other apps from inside a webapp using a proprietary scheme identifier. Unfortunately, you will need to know the exact scheme syntax in advance. There's a good list of them available here:
http://wiki.akosma.com/IPhone_URL_Schemes
For example, to open the youtube app directly, you can use:
youtube://