Как я могу использовать местоположение выставки в живом приложении, оно работает в приложении и эмуляторе Expo dev, но разрушает производственное приложение - PullRequest
0 голосов
/ 09 июля 2020

Я разрабатываю приложение, которое позволяет пользователю выбирать координаты своего адреса на картах Google. Эмулированное приложение работает нормально, но когда я создаю apk для тестирования, оно продолжает работать, и ошибок не отображается. Я запрашиваю разрешения на местоположение и точно получаю местоположение пользователя при тестировании. Мое приложение. json похоже на это.

 "android": {
      "package": "zw.co.buffalos24.app",
      "versionCode": 1,
      "permissions": [
        "VIBRATE",
        "WRITE_EXTERNAL_STORAGE",
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION"
      ]
    }

Место выбора кода адреса создания выглядит следующим образом

React.useEffect(() => {
        (async () => {
            let { status } = await Permissions.askAsync(Permissions.LOCATION);
            if (status !== 'granted') {
                setErrorMsg('Permission to access location was denied');
            }
            let location;
            if(!address?.coords){
                try {
                    location = await Location.getCurrentPositionAsync({
                        enableHighAccuracy: true,
                        distanceInterval: 1,
                        timeInterval: 1000
                    });       
                    let { coords: { latitude, longitude } } = location;
                    let newAddress = {...address, coords: { latitude, longitude }};
                    updateAddress(newAddress); 
                    setLocation(location);
                } catch (error) {
                    setErrorMsg(error.message);
                }
            }
        })();
    },[address]);

, а мой jsx

{errorMsg && <Text style={{marginBottom: 8, color: "#f33"}}>{errorMsg}</Text>}
        {(location && address?.coords) && 
            <View style={{position: "relative", height: 140, backgroundColor: "#fff", justifyContent: "flex-end", alignItems: "center"}}>
                <MapView.Animated
                        initialRegion={{
                            ...address?.coords,
                            longitudeDelta: .05,
                            latitudeDelta: .04
                        }}
                        minZoomLevel={16}
                        maxZoomLevel={32}
                        zoomEnabled
                        style={{ width: "100%", height: 140}}
                    >
                        <Marker
                            coordinate={address?.coords}
                            title={address?.name}
                        />
                    </MapView.Animated>
                <View style={{position: "absolute", bottom: 16, zIndex: 999}}>
                    <TouchableOpacity
                        style={{alignSelf:"center", padding: 8, backgroundColor: "#fa0b", borderRadius: 16 }}
                        activeOpacity={.8}
                        onPress={()=> navigate("LocationPicker", {
                            updateLocation: coords => updateLocation(coords),
                            currentLocation: address.coords
                        })}
                    >
                        <Text>Update your location</Text>
                    </TouchableOpacity>
                </View>
            </View>
        }

- есть что-то, что мне не хватает, что может привести к сбою приложения sh?

...