权限请求未显示在ios上以进行位置共享

时间:2019-07-03 07:31:18

标签: google-maps react-native geolocation authorization frontend

我一直在尝试使位置权限请求生效。最初是这样做的,但是在重置模拟器并在ios中尝试其他模拟器后,它不再出现。为确保确定,我已重置设备以再次对其进行测试。以下是相关部分中的info.plist和代码。感谢您的尝试

info.plist:

<?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>mApp</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>NSLocationWhenInUseUsageDescription</key>
    <string/>
    <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/>
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
      <key>NSExceptionDomains</key>
      <dict>
        <key>localhost</key>
        <dict>
          <key>NSExceptionAllowsInsecureHTTPLoads</key>
          <true/>
        </dict>
      </dict>
    </dict>
    <key>UIAppFonts</key>
    <array>
      <string>Ionicons.ttf</string>
      <string>AntDesign.ttf</string>
      <string>Entypo.ttf</string>
      <string>EvilIcons.ttf</string>
      <string>Feather.ttf</string>
      <string>FontAwesome.ttf</string>
      <string>FontAwesome5_Brands.ttf</string>
      <string>FontAwesome5_Regular.ttf</string>
      <string>FontAwesome5_Solid.ttf</string>
      <string>Foundation.ttf</string>
      <string>MaterialCommunityIcons.ttf</string>
      <string>MaterialIcons.ttf</string>
      <string>Octicons.ttf</string>
      <string>SimpleLineIcons.ttf</string>
      <string>Zocial.ttf</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
      <string>location</string>
      <string>fetch</string>
    </array>
    <key>NSLocationWhenInUseUsageDescription</key>
      <string>CHANGEME: Location Always Usage Description</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>CHANGEME: Location Always Usage Description</string>
    <key>NSMotionUsageDescription</key>
    <string>CHANGEME: Motion updates increase battery efficiency by intelligently toggling location-services when device is detected to be moving</string>
  </dict>
</plist>

代码:

class Home extends React.Component{
  componentDidMount(){
    navigator.geolocation.requestAuthorization()
  }
  render(){

    return(
   <View style={styles.container}>

     <MapView showUserLocation={true}
     // remove if not using Google Maps
     customMapStyle={mapStyle}
     provider={PROVIDER_GOOGLE} 
       style={styles.map}
       region={{
         latitude: 37.78825,
         longitude: -122.4324,
         latitudeDelta: 0.015,
         longitudeDelta: 0.0121,
       }}
     >


     </MapView>

     <MenuIcon navigation={this.props.navigation}/>

   </View>
)
     }}

     export default createAppContainer(createSwitchNavigator(
      {
       Home: Home,
       Other: Altern
      },
      {
        initialRouteName: 'Home',
      }
    ));

设置:

enter image description here

0 个答案:

没有答案
相关问题