mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
improve intent with scheduler
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { Filesystem } from '@capacitor/filesystem';
|
||||
import { SendIntent } from "send-intent";
|
||||
import { Router } from '@angular/router';
|
||||
import { CallbackScheduler } from './callbackScheduler';
|
||||
|
||||
class SendIntent {
|
||||
|
||||
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)=> {
|
||||
let resultUrl = decodeURIComponent(result.url);
|
||||
Filesystem.readFile({path: resultUrl}).then(async (content) => {
|
||||
|
||||
this.Router.navigateByUrl("/home/publication");
|
||||
|
||||
alert('shared')
|
||||
console.log(content.data);
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export const sendIntent = new SendIntent()
|
||||
Reference in New Issue
Block a user