Running a non-Ionic CapacitorJS app in ReactJS. I implemented deep links in accordance with the documentation - and it works 100% in Android, I can select a link from notepad app and it will launch to that direct page in my app.
But in iOS, deep links work only 50% - selecting the link from notes app successfully opens my iOS app but not to the direct page, only my default route. I suspect it must have something to do with my appURLlistener component:
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { App, URLOpenListenerEvent } from '@capacitor/app';
export const AppUrlListener = () => {
let navigate = useNavigate();
useEffect(() => {
App.addListener("appUrlOpen", event => {
// Example url: https://beerswift.app/tabs/tab2
// slug = /tabs/tab2
const slug = event.url.split(".com/#/").pop()
if (slug) {
navigate(slug);
} else {
navigate("/home");
}
// If no match, do nothing - let regular routing
// logic take over
})
}, [])
return null
};
I am using HashRouter as you can see. Like I said: the above configuration works fine in Android and links directly to the specific app page (e.g. “/content/example1”) but only takes me to the app in general on iOS, not to my specific page.
I can share details on Xcode configuration if relevant but considering the app does get pulled when selecting a link (just not to my direct page), I suspect that portion of my configuration is fine and it is the URL handling which is being somehow screwed-up.