mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: support deep links
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 StApps
|
||||
* Copyright (C) 2018-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -12,7 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, NgZone} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {App, URLOpenListenerEvent} from '@capacitor/app';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
@@ -47,12 +49,16 @@ export class AppComponent {
|
||||
* @param settingsProvider TODO
|
||||
* @param configProvider TODO
|
||||
* @param logger An angular logger
|
||||
* @param router The angular router
|
||||
* @param zone The angular zone
|
||||
*/
|
||||
constructor(
|
||||
private readonly platform: Platform,
|
||||
private readonly settingsProvider: SettingsProvider,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
private readonly logger: NGXLogger,
|
||||
private readonly router: Router,
|
||||
private readonly zone: NgZone,
|
||||
) {
|
||||
void this.initializeApp();
|
||||
}
|
||||
@@ -61,6 +67,16 @@ export class AppComponent {
|
||||
* TODO
|
||||
*/
|
||||
async initializeApp() {
|
||||
App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => {
|
||||
this.zone.run(() => {
|
||||
const slug = event.url.split('.de').pop();
|
||||
if (slug) {
|
||||
this.router.navigateByUrl(slug);
|
||||
}
|
||||
// If no match, do nothing - let regular routing
|
||||
// logic take over
|
||||
});
|
||||
});
|
||||
this.platform.ready().then(async () => {
|
||||
await SplashScreen.hide();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user