Геолокация React-Native работает на устройстве Android, но не на iPhone - PullRequest
0 голосов
/ 25 сентября 2019

Использование модуля геолокацииact-native на андроиде работает нормально, но на устройстве iphone не работает ни сообщение об ошибке какой-либо из функций модуля

Я пытался использовать прямой метод на компоненте страницы в качестве функцииэто делает его асинхронным, но он не работает, использование действия, проходящего через промежуточное программное обеспечение саги, также не работает.Я перепробовал все методы модуля и ни один из них у меня нет ответа

Позиция компонента (страница)

import React, {useState, useEffect} from 'react';
import {useDispatch, useSelector} from 'react-redux';

import {Container, Image} from './styles';

import * as PositionActions from '../../store/modules/position/action';

import Header from '../../components/Header';
import Button from '../../components/Button';
import ButtonGroup from '../../components/ButtonGroup';
import Fundo from '../../../assets/images/FundoPosicionamento.png';

export default function Position() {

  const dispatch = useDispatch();

  function handlePositionDot(dot) {
    dispatch(PositionActions.PositionRequest(dot));
  }

  return (
    <Container>
      <Image source={Fundo} resizeMode="stretch">
        <Header buttonExist={false} />
        <ButtonGroup

          functionOnPressA={() => handlePositionDot(true)}
        />
      </Image>
    </Container>
  );
}

Позиция действий

export function PositionRequest(dot) {
  return {
    type: '@position/REQUEST_POSITION',
    payload: {
      dot,
    },
  };
}

Позиция саг

import Geolocation from '@react-native-community/geolocation';

function getCurrentPosition() {
  return new Promise((resolve, reject) => {
    Geolocation.getCurrentPosition(resolve, reject, {
      enableHighAccuracy: true,
      timeout: 15000,
      maximumAge: 500,
    });
  });
}

function* requestPosition(action) {
  yield put(
    PositionLoadingActivityOnDot('gravando informações...', action.payload.dot)
  );
  try {
    const position = yield call(getCurrentPosition);
    console.tron.log(position)
    const {accuracy, altitude, longitude, latitude} = position.coords;
    yield put(
      PositionRequestSuccess(
        'coletada localização com sucesso',
        action.payload.dot,
        accuracy,
        altitude,
        longitude,
        latitude
      )
    );
  } catch (err) {
    yield put(
      PositionRequestFailure(
        '005-erro de localização verifique seu smartphone',
        action.payload.dot
      )
    );
  }
}

pakcage.json

  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "@react-native-community/geolocation": "^2.0.2",
    "axios": "^0.19.0",
    "immer": "^4.0.0",
    "prop-types": "^15.7.2",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-masked-text": "^1.13.0",
    "react-native-reanimated": "^1.2.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.0.3",
    "react-navigation-stack": "^1.5.5",
    "react-redux": "^7.1.1",
    "reactotron-react-native": "^3.6.5",
    "reactotron-redux": "^3.1.1",
    "reactotron-redux-saga": "^4.2.2",
    "redux": "^4.0.4",
    "redux-saga": "^1.0.5",
    "styled-components": "^4.3.2"
}

информационная система

System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-2675QM CPU @ 2.20GHz
    Memory: 33.22 MB / 4.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.0
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.2 AI-181.5540.7.32.5056338
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.5 => 0.60.5
  npmGlobalPackages:
    react-native-cli: 2.0.1

info.pslist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>Betta Hidroturbinas</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>NSLocationAlwaysAndWhenInUseUsageDescription</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string></string>
    <key>UIAppFonts</key>
    <array>
        <string>Roboto-Black.ttf</string>
        <string>Roboto-BlackItalic.ttf</string>
        <string>Roboto-Bold.ttf</string>
        <string>Roboto-BoldItalic.ttf</string>
        <string>Roboto-Light.ttf</string>
        <string>Roboto-LightItalic.ttf</string>
        <string>Roboto-Medium.ttf</string>
        <string>Roboto-MediumItalic.ttf</string>
        <string>Roboto-Regular.ttf</string>
        <string>Roboto-RegularItalic.ttf</string>
        <string>Roboto-Thin.ttf</string>
        <string>Roboto-ThinItalic.ttf</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

Не ошибка, не возврат,в реактотроне https://ibb.co/0M54GMC

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...