Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Filter available apps by key

I am getting the number of apps installed on device, how can I filter them to only include the keys, google_maps and apple_maps ?

List of apps:

mapsAppInfo = {
baidu: false
cabify: false
citymapper: false
ee.mtakso.client: true
gaode: false
google_maps: true
here_maps: false
lyft: false
maps_me: false
moovit: false
sygic: false
taxis_99: false
uber: true
waze: false
yandex: false
}



  useEffect(() => {
    const loadAvailableMapApps = async () => {
      const mapsAppInfo = (await launcNavigator.getAvailableApps()) as AppInfo;
      
      const availableApps = Object.keys(mapsAppInfo).filter(
        (key) => mapsAppInfo[key],
      );

      setAvailableMapApps(availableApps);
    };

    // eslint-disable-next-line no-void
    void loadAvailableMapApps();
  }, []);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The easiest way would probably be to filter them by hand in your case. You can add another filter before the one you already have:

const availableApps = Object.keys(mapsAppInfo)
    .filter(k => (k === "google_maps" || k === "apple_maps")
    .filter(
        (key) => mapsAppInfo[key],
    );
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading