mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 06:22:53 +00:00
feat: support deep links
This commit is contained in:
@@ -22,6 +22,14 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
<!-- NEXT LINE'S HOST TO BE GENERATED (SCHOOL SPECIFIC) -->
|
||||||
|
<data android:scheme="https" android:host="mobile.app.uni-frankfurt.de" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {AppComponent} from './app.component';
|
|||||||
import {ConfigProvider} from './modules/config/config.provider';
|
import {ConfigProvider} from './modules/config/config.provider';
|
||||||
import {SettingsProvider} from './modules/settings/settings.provider';
|
import {SettingsProvider} from './modules/settings/settings.provider';
|
||||||
import {NGXLogger} from 'ngx-logger';
|
import {NGXLogger} from 'ngx-logger';
|
||||||
|
import {RouterTestingModule} from '@angular/router/testing';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
let platformReadySpy: any;
|
let platformReadySpy: any;
|
||||||
@@ -54,6 +55,7 @@ describe('AppComponent', () => {
|
|||||||
ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']);
|
ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']);
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [RouterTestingModule.withRoutes([])],
|
||||||
declarations: [AppComponent],
|
declarations: [AppComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: Platform, useValue: platformSpy},
|
{provide: Platform, useValue: platformSpy},
|
||||||
|
|||||||
@@ -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
|
* 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
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
* Software Foundation, version 3.
|
* Software Foundation, version 3.
|
||||||
@@ -12,7 +12,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 {SplashScreen} from '@capacitor/splash-screen';
|
||||||
import {Platform} from '@ionic/angular';
|
import {Platform} from '@ionic/angular';
|
||||||
import {NGXLogger} from 'ngx-logger';
|
import {NGXLogger} from 'ngx-logger';
|
||||||
@@ -47,12 +49,16 @@ export class AppComponent {
|
|||||||
* @param settingsProvider TODO
|
* @param settingsProvider TODO
|
||||||
* @param configProvider TODO
|
* @param configProvider TODO
|
||||||
* @param logger An angular logger
|
* @param logger An angular logger
|
||||||
|
* @param router The angular router
|
||||||
|
* @param zone The angular zone
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private readonly platform: Platform,
|
private readonly platform: Platform,
|
||||||
private readonly settingsProvider: SettingsProvider,
|
private readonly settingsProvider: SettingsProvider,
|
||||||
private readonly configProvider: ConfigProvider,
|
private readonly configProvider: ConfigProvider,
|
||||||
private readonly logger: NGXLogger,
|
private readonly logger: NGXLogger,
|
||||||
|
private readonly router: Router,
|
||||||
|
private readonly zone: NgZone,
|
||||||
) {
|
) {
|
||||||
void this.initializeApp();
|
void this.initializeApp();
|
||||||
}
|
}
|
||||||
@@ -61,6 +67,16 @@ export class AppComponent {
|
|||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
async initializeApp() {
|
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 () => {
|
this.platform.ready().then(async () => {
|
||||||
await SplashScreen.hide();
|
await SplashScreen.hide();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user