简体   繁体   中英

Ionic App Availability plugin getting Error Object (...) is not a function

I am trying to implement App Availability Feature in ionic. I have an app installed in my device and trying to check if that app exists from another app. But facing an issue in the same, getting the below error

在此处输入图片说明

Possibly you are facing mismatch of ionic version of app and the plugin version you installed in your app. In Ionic V3 you no need to import from '../ngx';

Ionic V3 and V4 have Different plugin url

Ionic v3 plugins

Ionic v4 plugins .

For Ionic v3 App availability

 ionic cordova plugin add cordova-plugin-appavailability
 npm install --save @ionic-native/app-availability@4

And for Ionic V4 App availability

ionic cordova plugin add cordova-plugin-appavailability
npm install @ionic-native/app-availability

npm install cmd is different for both version

Try this steps

  1. remove plugin
  2. Add plugin for ionic V3 compatible from here
  3. Try to build now

I had this error: with the Ionic 5/ Capacitor app.

core.js:6479 ERROR Error: Uncaught (in promise): [object String] at resolvePromise (zone.js:1255) at zone.js:1162 at rejected (tslib.es6.js:74) at ZoneDelegate.invoke (zone.js:400) at Object.onInvoke (core.js:28705) at ZoneDelegate.invoke (zone.js:399) at Zone.run (zone.js:160) at zone.js:1318 at ZoneDelegate.invokeTask (zone.js:434) at Object.onInvokeTask (core.js:28692) defaultErrorLogger @ core.js:6479

I have used this code and works fine now. The problem for me was I didn't have Instagram App installed on my device. So it throws an exception. I have handled it like so:

async goToInstagram(): Promise<void> {
    let app: string;

    if (this.platform.is('ios')) {
      app = 'instagram://';
    } else if (this.platform.is('android')) {
      app = 'com.instagram.android';
    }

    try {
      const isAppAvailable = await this.appAvailability.check(app);

      isAppAvailable
        ? this.inAppBrowser.create(`instagram://user?username=${this.item.instagram}`, '_system')
        : this.inAppBrowser.create(`https://www.instagram.com/${this.item.instagram}`, '_system');
    } catch (err) {
      this.inAppBrowser.create(`https://www.instagram.com/${this.item.instagram}`, '_system');
    }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM