Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!