tschoffelen / react-native-map-link

🗺 Open the map app of the user's choice.
MIT License
648 stars 137 forks source link

Missing apps: Doesn't detect all installed apps #279

Closed ansmlc closed 4 months ago

ansmlc commented 5 months ago

I'm testing this library and I've noticed it doesn't detect all available apps. I've followed the managed expo workflow guide.

On my phone (iOS) I have following apps installed:

However, the lib only detects Apple Maps and Waze. (and Google Maps if alwaysIncludeGoogle is true).

This is my code:

import React, { useState, useEffect } from 'react';
import { Pressable, Text, View } from 'react-native';
import { Image } from 'expo-image';
import { getApps } from 'react-native-map-link';
import { GetAppsResponse } from 'react-native-map-link/lib/type';
import Colors from '@/src/constants/Colors';

type GetAppResult = {
  id: string;
  name: string;
  icon: NodeRequire;
  open: () => Promise<void>;
};

type DemoProps = {
  lat: number;
  long: number;
  title: string;
};

export const Demo: React.FC<DemoProps> = ({ lat, long, title }) => {
  const [availableApps, setAvailableApps] = useState<GetAppsResponse[]>([]);
  useEffect(() => {
    (async () => {
      const result = await getApps({
        latitude: lat,
        longitude: long,
        title: title,
        googleForceLatLon: true, // optionally force GoogleMaps to use the latlon for the query instead of the title
        alwaysIncludeGoogle: true, // optional, true will always add Google Maps to iOS and open in Safari, even if app is not installed (default: false)
      });
      setAvailableApps(result);
    })();
  }, []);

  return (
    <View style={{ flexDirection: 'column' }}>
      {availableApps.map(({ icon, name, id, open }) => (
        <Pressable
          key={id}
          onPress={open}
          style={{
            borderWidth: 1,
            borderColor: Colors.gray,
            borderRadius: 12,
            padding: 8,
            width: 120,
            display: 'flex',
            flexDirection: 'column',
            justifyContent: 'center',
            alignContent: 'center',
            alignItems: 'center',
            marginHorizontal: 4,
          }}
        >
          <Image source={icon} style={{ width: 25, height: 25 }} />
          <Text>{name}</Text>
        </Pressable>
      ))}
    </View>
  );
};

Screenshot

image
tschoffelen commented 5 months ago

Hi there - just to confirm, could you double check you've recompiled the app after adding the app.json config?

ansmlc commented 5 months ago

Hi, yes, if I check ios/app/Info.plist, it has this array:

    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>comgooglemaps</string>
      <string>citymapper</string>
      <string>uber</string>
      <string>lyft</string>
      <string>transit</string>
      <string>truckmap</string>
      <string>waze</string>
      <string>yandexnavi</string>
      <string>moovit</string>
      <string>yandextaxi</string>
      <string>yandexmaps</string>
      <string>kakaomap</string>
      <string>tmap</string>
      <string>szn-mapy</string>
      <string>mapsme</string>
      <string>osmandmaps</string>
      <string>gett</string>
      <string>nmap</string>
      <string>dgis</string>
      <string>lftgpas</string>
    </array>

I'm checking this by running a preview build on iOS device via the Expo Go app. Could this be the reason? But than again, how does it detect Waze.

Also, on Android it works fine - it detects almost all apps (except Maps.me).

tschoffelen commented 4 months ago

Oh I see! The Expo Go app has it's own whitelist of applications - which does include Waze, but none of the others:

https://github.com/expo/expo/blob/main/apps/expo-go/ios/Exponent/Supporting/Info.plist#L75-L82

ansmlc commented 4 months ago

Oh I see! The Expo Go app has it's own whitelist of applications - which does include Waze, but none of the others:

https://github.com/expo/expo/blob/main/apps/expo-go/ios/Exponent/Supporting/Info.plist#L75-L82

Ohh, I had no idea. So just to confirm, to really test the lib I'll need Apple's Dev account and install the app directly on the device, right? Since on the Simulator there's no App Store so can't install any navigation apps.

tschoffelen commented 4 months ago

So just to confirm, to really test the lib I'll need Apple's Dev account and install the app directly on the device, right?

Yes, correct! Unfortunately that's the only way I'm aware of for Apple devices.

ansmlc commented 4 months ago

@tschoffelen Any idea why maps.me doesn't show up on Android? All other apps show up as expected. Tested on two different Android devices.

EDIT: related issue?