import { Injectable } from '@angular/core'; import { Deeplinks } from '@ionic-native/deeplinks'; import * as routeUtils from 'ionic/lib/route'; import { BaseLog as Log } from 'base-log'; const log = new Log('NativeLink'); // == 用于原生与原生,浏览器与原生之间跳转 @Injectable() export class NativeLink{ constructor(public deeplinks:Deeplinks) { } subscribe = (cb) => { const config = routeUtils.getAll(false, 'nativeLink'); this.deeplinks.route(config).subscribe((match) => { const path = match.$link.path; const params = match.$args || {}; cb({ path, params, match }); log.info('native link match',JSON.stringify(match),true); }, (nomatch) => { cb({ match: nomatch }); log.info('native link nomatch',JSON.stringify(nomatch),true); }); } }