Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
Call a Ionic provider function from global javascript scope

I want to call a function (TagDataSubscriber.next) from a global scope JavaScript function. It's a bridge between Flutter app and my Ionic app. Any idea how to achieve that? I found a app-injector somewhere in the internet, but it won't work.

Regards, Markus

import {Injector} from '@angular/core';

let appInjectorRef: Injector;
export const AppInjector = (injector?: Injector): Injector => {
  if (injector) {
    appInjectorRef = injector;
  }
  return appInjectorRef;
};

Provider file:

import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subscriber} from 'rxjs/Subscriber';
import {AppInjector} from "../../app/app-injector";

/* function called by Flutter if a NFC tag was detected */
window["nfcTagReceived"] = function (nfcTag) {
  let injector = AppInjector();
  let nfcService = injector.get(NfcServiceProvider);
  nfcService.TagDataSubscriber.next(nfcTag);
}

@Injectable()
export class NfcServiceProvider {
  private nfcAvailable: boolean = false;
  private tagDataSubscriber: Subscriber<any>;
  private tagRead: Observable<number> = new Observable<number>(
    observer => this.tagDataSubscriber = observer
  );

  public get TagDataSubscriber(): Subscriber<any> {
    return this.tagDataSubscriber;
  }

  public get TagRead(): Observable<number> {
    /*Uncomment*ReadNfcOnce.postMessage("");*Uncomment*/
    return this.tagRead;
  }

  public get NfcAvailable(): boolean {
    return this.nfcAvailable;
  }

  constructor() {
  }
}
about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda