admin管理员组文章数量:1391999
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)
})
}
...
}
本文标签: androidHow to make App Link open on respective route in capacitor appStack Overflow
版权声明:本文标题:android - How to make App Link open on respective route in capacitor app? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744711154a2621136.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论