Is it possible to do a 3rd-party redirect back to mobile app?

I’m trying to implement Stripe checkout in my app. It works fine in a web browser, but I’m having a little bit of trouble with the Android app.

Here’s the workflow:

  • I redirect the user to the Stripe checkout page (not hosted on my server). I pass a redirect URL to Stripe.
  • Once the payment is complete or canceled, Stripe redirects back to my site with the URL I passed to them.

There’s no problem on the web browser, but on the mobile app the redirect wasn’t working. To make the redirect to Stripe work, I had to add this line to my mobile-config.js file:

App.accessRule('*', { type: 'navigation' });

OK, so then the redirect to stripe worked back, but then the redirect back to my site didn’t work, so I added this line to allow redirecting back to my site:

App.accessRule('*', { type: 'navigation' });

It does go to my site, but it seems like it’s opening the URL in an embedded browser separate from the app. It acts as if the user started a fresh session in a web browser (the user is logged out and Meteor.isCordova() is false).

Is there any way to make the redirect go back to the app?


This is called Universal Links on iOS and Deep Links on Android.

There are various cordova plugins which support both. Unfortunately the most commonly referenced version is outdated and is no longer supported. I currently use this fork: which works for me, but I see that this exists now as well:

There’s a bit of setup involved, particularly for iOS, but once all that’s done it boils down to this:

//// mobile-config.js
// meteor add cordova:cordova-universal-links-plugin@
    <ios-team-id value="<insert your teamId here>" />
    <host name="*" scheme="https" />
App.setPreference('AndroidLaunchMode', 'singleInstance');

//// client code
document.addEventListener("deviceready", () => {
	// handle external links to our app
	universalLinks.subscribe(null, (e) => {
		router.push(e.url.split('.com')[1]); // this automatically includes #hash and ?query parts of url.

I think I found a simpler solution. It seems on the Android app, the actual URL used internally is some localhost URL (http://localhost:12768)

I have the client pass the window.location.href to the server, then the server will send it to stripe, and then when it redirects back to the localhost URL it seems to work correctly.

Does this work on iOS?

I have no idea. I don’t have iOS, so I haven’t tried it.

Are you planning on supplying an iOS app to your iPhone/iPad users? If so you’ll at least need a device to test on. You’ll also need to pay for an Apple Developer Licence and technically you also need to get a Mac to compile the app on, although with a lot of messing around it is possible to do it within a virtual machine. (so I’ve read, wouldn’t dream of trying it myself :wink: )

I don’t have any plans to release anything to iOS unless I get an iOS device.

Thanks, this was helpful. For Step 3 of the iOS config:

Upload `apple-app-site-association` file in the root of your domain.

Where did you end up putting that file?

Any other tips for iOS? For some reason I’m not seeing anything fire on the universalLinks.subscribe function. I’m using

Just put that in your /public folder, then it’s available from https://your.domain/apple-app-site-association and Apple can download it to verify that you own the domain.

Once you’ve done that it should start working. However, I’m not sure when Apple checks for the existence of that file - it might only be when you install the app, so you might have to uninstall the app and re-install it once that file is in place on your server.

Also, notice that this page says:

Upload the apple-app-site-association file to your HTTPS web server

Is your server using https?

1 Like