{"action":"created","issue":{"url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/406","repository_url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation","labels_url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/406/labels{/name}","comments_url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/406/comments","events_url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/406/events","html_url":"https://github.com/transistorsoft/react-native-background-geolocation/issues/406","id":295356040,"number":406,"title":"Android: Location Permission is disabled ","user":{"login":"xinlangzi","id":1171370,"avatar_url":"https://avatars3.githubusercontent.com/u/1171370?v=4","gravatar_id":"","url":"https://api.github.com/users/xinlangzi","html_url":"https://github.com/xinlangzi","followers_url":"https://api.github.com/users/xinlangzi/followers","following_url":"https://api.github.com/users/xinlangzi/following{/other_user}","gists_url":"https://api.github.com/users/xinlangzi/gists{/gist_id}","starred_url":"https://api.github.com/users/xinlangzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xinlangzi/subscriptions","organizations_url":"https://api.github.com/users/xinlangzi/orgs","repos_url":"https://api.github.com/users/xinlangzi/repos","events_url":"https://api.github.com/users/xinlangzi/events{/privacy}","received_events_url":"https://api.github.com/users/xinlangzi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-08T01:41:32Z","updated_at":"2018-02-08T01:57:02Z","closed_at":null,"author_association":"NONE","body":"My release app is installed in my android phone, but the location permission is disabled on the setting. I have to manually enable it.\r\n\r\n## Your Environment\r\n* Plugin version: 2.10.1\r\n* Platform: Android\r\n* OS version: 8.1.0\r\n* Device manufacturer / model: Pixel 2 XL\r\n* React Native version (`react-native -v`): 0.51.0\r\n* Plugin config\r\n\r\n```\r\nimport React from 'react';\r\nimport Icon from 'react-native-vector-icons/Ionicons';\r\nimport { AppState, AsyncStorage, View, Platform, BackHandler } from 'react-native';\r\nimport { Navigation } from 'react-native-navigation';\r\nimport BackgroundGeolocation from \"react-native-background-geolocation\";\r\nvar Device = require('../libs/device');\r\n\r\nvar chatIcon;\r\nvar chatOutlineIcon;\r\nvar homeIcon;\r\nvar homeOutlineIcon;\r\n\r\nexport default class Main extends React.Component {\r\n\r\n  constructor(props) {\r\n    super(props);\r\n    this.state = {\r\n      server: this.props.server,\r\n      token: this.props.token,\r\n      name: this.props.name,\r\n      role: this.props.role,\r\n      userId: this.props.userId,\r\n      dispatchers: this.props.dispatchers\r\n    }\r\n  }\r\n\r\n  componentWillMount() {\r\n    console.log(\"Main componentWillMount\");\r\n    BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPressed);\r\n    this._populateIcons().then(()=>{\r\n      this._buildTabs();\r\n    }).catch((error) => {\r\n      console.error(error);\r\n    });\r\n  }\r\n\r\n  componentDidMount(){\r\n    console.log(\"Main componentDidMount\");\r\n    this._startBackgroundLocation();\r\n  }\r\n\r\n  // You must remove listeners when your component unmounts\r\n  componentWillUnmount() {\r\n    console.log(\"Main componentWillUnmount\");\r\n    BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPressed);\r\n    // Remove BackgroundGeolocation listeners\r\n    // BackgroundGeolocation.removeListeners();\r\n  }\r\n\r\n  onBackButtonPressed() {\r\n    return true;\r\n}\r\n\r\n  _populateIcons = function () {\r\n    return new Promise(function (resolve, reject) {\r\n      Promise.all(\r\n        [\r\n          Icon.getImageSource('ios-chatbubbles', 30),\r\n          Icon.getImageSource('ios-chatbubbles-outline', 30),\r\n          Icon.getImageSource('ios-home', 30),\r\n          Icon.getImageSource('ios-home-outline', 30),\r\n        ]\r\n      ).then((values) => {\r\n        chatIcon = values[0];\r\n        chatOutlineIcon = values[1];\r\n        homeIcon = values[2];\r\n        homeOutlineIcon = values[3];\r\n        resolve(true);\r\n      }).catch((error) => {\r\n        console.log(error);\r\n        reject(error);\r\n      }).done();\r\n    });\r\n  };\r\n\r\n  _buildTabs(){\r\n    Navigation.startTabBasedApp({\r\n      tabs: [\r\n        {\r\n          label: 'Home',\r\n          screen: 'HomeTab', // this is a registered name for a screen\r\n          icon: homeIcon,\r\n          selectedIcon: homeOutlineIcon,\r\n          title: 'Home',\r\n          navigatorStyle: {\r\n            navBarHidden: true\r\n          }\r\n        },\r\n        {\r\n          label: 'Chat',\r\n          screen: 'ChatTab',\r\n          icon: chatIcon,\r\n          selectedIcon: chatOutlineIcon,\r\n          title: 'Chat'\r\n        }\r\n      ],\r\n      passProps: {\r\n        server: this.state.server,\r\n        token: this.state.token,\r\n        name: this.state.name,\r\n        role: this.state.role,\r\n        userId: this.state.userId,\r\n        dispatchers: this.state.dispatchers\r\n      },\r\n      appStyle: {\r\n\t\t\t\torientation: 'portrait'\r\n\t\t\t}\r\n    });\r\n  }\r\n\r\n  _startBackgroundLocation(){\r\n    // This handler fires whenever bgGeo receives a location update.\r\n    BackgroundGeolocation.on('location', this.onLocation, this.onError);\r\n    // This handler fires when movement states changes (stationary->moving; moving->stationary)\r\n    BackgroundGeolocation.on('motionchange', this.onMotionChange);\r\n    // This event fires when a change in motion activity is detected\r\n    BackgroundGeolocation.on('activitychange', this.onActivityChange);\r\n    // This event fires when the user toggles location-services authorization\r\n    BackgroundGeolocation.on('providerchange', this.onProviderChange);\r\n\r\n    let data = Device.infosWithData({ token: this.props.token });\r\n    BackgroundGeolocation.configure({\r\n      // Geolocation Config\r\n      desiredAccuracy: 0,\r\n      stationaryRadius: 25,\r\n      distanceFilter: 1000,\r\n      foregroundService: true,\r\n      // Activity Recognition\r\n      stopTimeout: 1,\r\n      // Application config\r\n      debug: false,              // <-- enable this hear sounds for background-geolocation life-cycle.\r\n      logLevel: BackgroundGeolocation.LOG_LEVEL_OFF, //LOG_LEVEL_VERBOSE or LOG_LEVEL_OFF\r\n      stopOnTerminate: false,   // <-- Allow the background-service to continue tracking when user closes the app.\r\n      startOnBoot: true,        // <-- Auto start tracking when device is powered-up.\r\n      url: this.props.server + '/mobiles/locations.json',\r\n      batchSync: true,          // <-- [Default: false] Set true to sync locations to server in a single HTTP request.\r\n      // autoSync: false,        // <-- [Default: true] Set true to sync each location to server as it arrives.\r\n      params: data,\r\n      httpRootProperty: \"data\",\r\n      locationTemplate: '{\"latitude\":<%= latitude %>,\"longitude\":<%= longitude %>,\"speed\":\"<%= speed %>\",\"utcTime\":\"<%= timestamp %>\"}'\r\n    }, (state)=> {\r\n      console.log(\"- BackgroundGeolocation is configured and ready: \", state.enabled);\r\n      if (!state.enabled) {\r\n        BackgroundGeolocation.start(function() {\r\n          console.log(\"- Start success\");\r\n          BackgroundGeolocation.changePace(true);\r\n        });\r\n      }else{\r\n        BackgroundGeolocation.changePace(true);\r\n      }\r\n    });\r\n  }\r\n\r\n  onLocation(location) {\r\n    console.log('- [event] location: ', location);\r\n  }\r\n  onError(error) {\r\n    console.warn('- [event] location error ', error);\r\n  }\r\n  onActivityChange(activity) {\r\n    console.log('- [event] activitychange: ', activity);  // eg: 'on_foot', 'still', 'in_vehicle'\r\n  }\r\n  onProviderChange(provider) {\r\n    console.log('- [event] providerchange: ', provider);\r\n  }\r\n  onMotionChange(location) {\r\n    console.log('- [event] motionchange: ', location.isMoving, location);\r\n  }\r\n\r\n  render() {\r\n    return <View/>;\r\n  }\r\n}\r\n\r\n```\r\n\r\n## Expected Behavior\r\nThe location permission should be enabled. \r\n\r\n## Actual Behavior\r\nThe location permission is disabled, I have to manually enable.\r\n\r\n## Context\r\nHope my user on this android app with enabled location permission default. \r\n"},"comment":{"url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/comments/363976986","html_url":"https://github.com/transistorsoft/react-native-background-geolocation/issues/406#issuecomment-363976986","issue_url":"https://api.github.com/repos/transistorsoft/react-native-background-geolocation/issues/406","id":363976986,"user":{"login":"haobole","id":361813,"avatar_url":"https://avatars2.githubusercontent.com/u/361813?v=4","gravatar_id":"","url":"https://api.github.com/users/haobole","html_url":"https://github.com/haobole","followers_url":"https://api.github.com/users/haobole/followers","following_url":"https://api.github.com/users/haobole/following{/other_user}","gists_url":"https://api.github.com/users/haobole/gists{/gist_id}","starred_url":"https://api.github.com/users/haobole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haobole/subscriptions","organizations_url":"https://api.github.com/users/haobole/orgs","repos_url":"https://api.github.com/users/haobole/repos","events_url":"https://api.github.com/users/haobole/events{/privacy}","received_events_url":"https://api.github.com/users/haobole/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T01:57:02Z","updated_at":"2018-02-08T01:57:02Z","author_association":"NONE","body":"I am posting this for @xinlangzi : \r\n\r\n```\r\n02-07 19:52:05.271 32642-32642/? I/TSLocationManager: [c.t.l.util.Sensors print] \r\n                                                      ╔═════════════════════════════════════════════\r\n                                                      ║ DEVICE SENSORS\r\n                                                      ╠═════════════════════════════════════════════\r\n                                                      ╟─ ✅  ACCELEROMETER: {Sensor name=\"LSM6DSM Accelerometer\", vendor=\"STMicroelectronics\", version=1, type=1, maxRange=156.9064, resolution=0.0023956299, power=0.15, minDelay=2500}\r\n                                                      ╟─ ✅  GYROSCOPE: {Sensor name=\"LSM6DSM Gyroscope\", vendor=\"STMicroelectronics\", version=1, type=4, maxRange=17.453293, resolution=0.0012207031, power=0.45, minDelay=2500}\r\n                                                      ╟─ ✅  MAGNETOMETER: {Sensor name=\"AK09915 Magnetometer\", vendor=\"AKM\", version=1, type=2, maxRange=5160.0005, resolution=0.14953613, power=1.8, minDelay=10000}\r\n                                                      ╟─ ✅  SIGNIFICANT_MOTION: {Sensor name=\"Significant Motion\", vendor=\"Google\", version=2, type=17, maxRange=1.0, resolution=1.0, power=0.25, minDelay=-1}\r\n                                                      ╚═════════════════════════════════════════════\r\n02-07 19:52:05.289 32642-32642/? I/TSLocationManager: [c.t.l.a.BackgroundGeolocation <init>] \r\n                                                      ╔═════════════════════════════════════════════\r\n                                                      ║ BackgroundGeolocation adapter\r\n                                                      ╠═════════════════════════════════════════════\r\n02-07 19:52:05.299 32642-32642/? I/TSLocationManager: [c.t.l.a.BackgroundGeolocation <init>] \r\n                                                        ✅  Google Play Services: connected (version code:11910000)\r\n02-07 19:52:05.325 32642-32642/? D/TSLocationManager: [c.t.l.data.sqlite.a onCreate] CREATE TABLE IF NOT EXISTS locations (id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT NOT NULL DEFAULT '', timestamp TEXT, json TEXT, locked BOOLEAN);\r\n02-07 19:52:05.332 32642-32642/? D/TSLocationManager: [c.t.l.data.sqlite.a onCreate] CREATE TABLE IF NOT EXISTS geofences (id INTEGER PRIMARY KEY AUTOINCREMENT, identifier TEXT NOT NULL UNIQUE, latitude DOUBLE NOT NULL, sin_latitude DOUBLE NOT NULL, cos_latitude DOUBLE NOT NULL, longitude DOUBLE NOT NULL, sin_longitude DOUBLE NOT NULL, cos_longitude DOUBLE NOT NULL, radius DOUBLE NOT NULL, notifyOnEntry BOOLEAN NOT NULL DEFAULT 0, notifyOnExit BOOLEAN NOT NULL DEFAULT 0, notifyOnDwell BOOLEAN NOT NULL DEFAULT 0, loiteringDelay INTEGER NOT NULL DEFAULT 0, extras TEXT);\r\n02-07 19:52:05.346 32642-32642/? D/TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO dbh] \r\n                                                        ✅  Opened database\r\n02-07 19:52:05.353 32642-32642/? D/TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO prune] \r\n                                                        ℹ️  PRUNE -1 days\r\n02-07 19:52:05.365 32642-32642/? D/TSLocationManager: [c.t.l.data.sqlite.GeofenceDAO dbh] \r\n                                                        ✅  Opened database\r\n02-07 19:52:05.376 32642-32642/? I/TSLocationManager: [c.t.l.a.BackgroundGeolocation <init>] \r\n                                                        🔵  Connecting to GooglePlayServices...\r\n```\r\n"}}
{"actor":{"display_login":"haobole"}}