Error: Uncaught (in promise): ReferenceError: MobileAccessibility is not defined ReferenceError: MobileAccessibility is not defined


#1

Hi,

I am trying to use the same font size in all devices, regardless of users font settings.
I imported this https://github.com/phonegap/phonegap-mobile-accessibility cordova plugin to disable user preferred text zoom but I can’t seem to get it to work.
Here is my code so far:

imports ...

declare var MobileAccessibility: any;

@Component({
...
})

export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage = UsersPage;
  pages: Array<{title: string, component: any}>;

  constructor(
    public platform: Platform,
    public menu: MenuController,
    public statusBar: StatusBar,
    public splashScreen: SplashScreen,
    public deploy: Deploy,
  ) {
    this.initializeApp();

    this.pages = [
      ...
    ];
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();

      MobileAccessibility.usePreferredTextZoom(false);
    });
  }

  openPage(page) {
    // close the menu when clicking a link from the menu
    this.menu.close();
    // navigate to the new page if it is not the current page
    this.nav.setRoot(page.component);
  }
}

When I try to run it I get the following error:

Error: Uncaught (in promise): ReferenceError: MobileAccessibility is not defined
ReferenceError: MobileAccessibility is not defined

All help is appreciated.


Trying to get https://github.com/phonegap/phonegap-mobile-accessibility to work in Ionic v2 to stop my App formatting changing with system font size changes in Android
#2

Why don’t you use https://ionicframework.com/docs/native/mobile-accessibility/?


#3

I thought I had tried that as well, after removing and adding it again it works like a charm. Thank you!

Sometimes when I am debugging via USB the screen just goes blank white and nothing happens, gets back to normal after restarting though.

By the way… do you know how I can set the default size to equal the size of “small” in android by chance?


#4

Nope, no experience with that, sorry.