Files
doneit-web/src/app/services/shareIntent.ts
T
2023-11-20 14:12:32 +01:00

47 lines
1.0 KiB
TypeScript

import { Filesystem } from '@capacitor/filesystem';
import { SendIntent } from "send-intent";
import { Router } from '@angular/router';
import { CallbackScheduler } from './callbackScheduler';
export class SendIntentService {
Router!: Router
callbackScheduler = new CallbackScheduler()
constructor() {
SendIntent.checkSendIntentReceived().then((result: any) => {
// logger
if (result) {
console.log('SendIntent received');
console.log(JSON.stringify(result));
}
// event handler
if (result.url) {
this.onReceive(result)
}
}).catch(err => console.error(err));
}
private initialize() {
this.callbackScheduler.start()
}
setRouteService(Router: Router) {
this.Router = Router
this.initialize()
}
private onReceive = this.callbackScheduler.function<any>((result)=> {
this.Router.navigateByUrl("/home/publications");
window["sharedContent"] = result;
})
}
export const sendIntent = new SendIntentService()