I would like to open a link in an android app that was built from a SvelteKit project (adapter-static
) and capacitor.
I've added the intent-filter
in AndroidManifest.xml
and the assetlinks.json
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="my-domain" />
</intent-filter>
Clicking a link like will open the app, but only the main page, not the route.
Is this expected and needs to be handled somewhere else? Like in the MainActivity
class? Or in the SvelteKit project by using @capacitor/app
and App.getLaunchUrl()
and/or App.addListener('appUrlOpen', (event) => {...})
?
(I tried the latter by adjusting the url in hooks.client.ts
and +layout.ts
without success and wonder if that's even the way to go...)
I would like to open a link in an android app that was built from a SvelteKit project (adapter-static
) and capacitor.
I've added the intent-filter
in AndroidManifest.xml
and the assetlinks.json
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="my-domain" />
</intent-filter>
Clicking a link like https://my-domain/route
will open the app, but only the main page, not the route.
Is this expected and needs to be handled somewhere else? Like in the MainActivity
class? Or in the SvelteKit project by using @capacitor/app
and App.getLaunchUrl()
and/or App.addListener('appUrlOpen', (event) => {...})
?
(I tried the latter by adjusting the url in hooks.client.ts
and +layout.ts
without success and wonder if that's even the way to go...)
1 Answer
Reset to default 0This section in the docs indicates that the routing is done in the frontend framework and only the 'appUrlOpen'
event needs to be handled
// +layout.js
import {browser} from '$app/environment';
import {Capacitor} from '@capacitor/core';
import {App as capacitorApp} from '@capacitor/app';
export async function load() {
const isNativePlatform = Capacitor.isNativePlatform()
if (browser && isNativePlatform) {
await capacitorApp.addListener('appUrlOpen', async (event) => {
const url = event.url
const urlInstance = new URL(url)
const navigateTo = urlInstance.pathname + urlInstance.search + urlInstance.hash
await goto(navigateTo)
})
}
...
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744711154a4589350.html
评论列表(0条)