Commit Graph

25 Commits

Author SHA1 Message Date
Marshall Roch 91b6b4efb9 @allow-large-files Flow v0.54.0
Reviewed By: leebyron

Differential Revision: D5773490

fbshipit-source-id: 2c54bb6326f23edbe9a969f3010f79da8189923e
2017-09-06 03:33:43 -07:00
Tikhon Botchkarev 61800414cb Reference PermissionsAndroid in Geolocation doc
Summary:
Current Geolocation API docs do not mention using PermissionAndroid when working with API 23+. This updates the docs to reflect that requirement.

This a documentation change, so no testing is required.
Closes https://github.com/facebook/react-native/pull/14133

Differential Revision: D5767852

Pulled By: hramos

fbshipit-source-id: 25af70db864a50cdc5e3765eccdeecd49c084d9a
2017-09-05 11:53:14 -07:00
Adam Comella 6b7f10d43e iOS: Geolocation: Allow skipping of permission prompts
Summary:
This change enables developers to tell the Geolocation module to skip its permissions requests so the app can manage the permissions requests on its own. React Native Android's Geolocation module already requires apps to request permissions on their own.

Currently, the Geolocation module automatically makes permissions requests for you based on what you've specified in your property list file. However, the property list file doesn't always represent what permissions the app wants right now. For example, suppose an app sometimes wants location when "in use" and sometimes wants location "always" depending on what app features the user has engaged with. The Geolocation API will request the "always" location permission even if that's not what the app wants for the current scenario.

This change enables developers to tell the Geolocation module to skip permission requests so that the app can explicitly ask for the appropriate permissions. By default, Geolocation will still ask for permissions so this is not a breaking change.

This change adds a method to Geolocation that is not supported by the web spec for geolocation (`setRNConfiguration`). This method includes `RN` in the name to minimize the chances that the web spec will introduce an API with the same name.

**Test plan (required)**

Verified that Geolocation requests permissions by default and when `skipPermissionRequests` is `false`. Verified the permission requests are skipped when `skipPermissionRequests` is `true`. Also, my team is using this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/15096

Differential Revision: D5725563

Pulled By: javache

fbshipit-source-id: fd23fedb7e57408fa0f0d0568e0f1ef2aea1cdd4
2017-08-29 04:23:04 -07:00
Jason Gaare f7043699b0 Use Apple's significant-change API (for iOS 11 UX)
Summary:
In the yet-to-be-released iOS 11, Apple has changed the way they notify the user of location services. (You can watch their session from WWDC about all the changes [here](https://developer.apple.com/videos/play/wwdc2017/713/).)

The current implementation of `RCTLocationObserver` uses the standard location services from Apple. When the user has granted `Always` location permission and the application uses the background location service, the user is presented with the *_Blue Bar of Shame_* (for more information check out [this blog post](https://blog.set.gl/ios-11-location-permissions-and-avoiding-the-blue-bar-of-shame-1cee6cd93bbe)):

![image](https://user-images.githubusercontent.com/15896334/28285133-281e425c-6af9-11e7-9177-61b879ab593c.png)

* Added `useSignificantChanges` boolean to the options passed.

* Added `_usingSignificantChanges` boolean based on user options. If `true`, then the CLLocationManager will use functions `startMonitoringSignificantLocationChanges`/ `stopMonitoringSignificantLocationChanges` rather than the standard location services.
* Changed method signature of `beginLocationUpdatesWithDesiredAccuracy` to include `useSignificantChanges` flag
* Added check for new `NSLocationAlwaysAndWhenInUseUsageDescription`

All unit tests passed.

Tested in simulator and on device, toggling `useSignificantChanges` option when calling `watchPosition`. Results were as expected. **When `TRUE`, the _Blue Bar of Shame_ was not present.**

Changes do not affect Android and location services still work as expected on Android.

* Change is for iOS only
* Using a different API will have different accuracy results. Adding `useSignificantChanges` as an option was by design so apps that want to have most accurate and most frequent update can still use standard location services.
Closes https://github.com/facebook/react-native/pull/15062

Differential Revision: D5443331

Pulled By: javache

fbshipit-source-id: 0cf5b6cd831c5a7c8c25a5ddc2e410a9aa989bf4
2017-07-24 11:23:10 -07:00
Alan Wang 09ba07e4fa fix error caused by first argument short when calling warning function
Summary:
<details>
  Thanks for submitting a PR! Please read these instructions carefully:

  - [X] Explain the **motivation** for making this change.
  - [] Provide a **test plan** demonstrating that the code is solid.
  - [X] Match the **code formatting** of the rest of the codebase.
  - [X] Target the `master` branch, NOT a "stable" branch.

  Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native.
</details>

My app crashed when I call navigator.geolocation.stopObserving(). I found it is caused by the reason that one argument short. So I added false to the first argument. Then bug is fixed.

1. call both navigator.geolocation.watchPosition and navigator.geolocation.getCurrentPosition
2. then call navigator.geolocation.stopObserving()
3. error happened before I fixed, and correct Warning "Called stopObserving with existing subscriptions." shown after I fixed.
Closes https://github.com/facebook/react-native/pull/14673

Differential Revision: D5301503

Pulled By: javache

fbshipit-source-id: 9e85064beb1052bb89bf42355ffd308fe9eaec53
2017-06-22 08:46:43 -07:00
Akshat Asawa 9e026ec358 Automatically request location permission when accessing geolocation
Reviewed By: achen1

Differential Revision: D5180727

fbshipit-source-id: 0c67ba31e3271f4ea5167a50119c132ef238cc25
2017-06-05 19:01:09 -07:00
Marcus do Nascimento 3c64d95413 Exposes requestAuthorization method.
Reviewed By: javache

Differential Revision: D5129014

fbshipit-source-id: 1e0be6a8a00a2f38ca7b5b20d891148c5ba97467
2017-05-25 07:07:50 -07:00
Adam Perry 0c9b41f2c0 Include Create React Native App in Getting Started
Summary:
cc hramos

Create React Native App was designed to reduce "time to hello world" to 5-10 minutes for React Native apps. This PR would make CRNA the first way to get started that new users encounter. Included also is some text to help advanced users navigate the question of whether to use CRNA or whether to go straight to `react-native init`. It also includes a new banner for the iOS and Android guides, since they do not apply to CRNA users.

Changes are only to the website, screenshots below. This branch was created from the last CI-passing master commit this morning, dependencies were freshly installed and these screenshots are from a clean build.

[The Getting Started page](https://www.dropbox.com/s/1s7f3wu3oxr6gpo/Screenshot%202017-04-04%2015.12.29.png?dl=0)

[The "native builds only" banner](https://www.dropbox.com/s/nyv51xdiibdkn57/Screenshot%202017-04-04%2015.13.25.png?dl=0)

[Pages which still apply to CRNApps have no banner](https://www.dropbox.com/s/qgl0h6uzynqkmy2/Screenshot%202017-04-04%2015.14.10.png?dl=0)

<details>

* [x] Decide how to handle native code & react-native-cli references outside of the `banner: ejected` guides
  * [x] [Debugging: Accessing Console Logs](https://facebook.github.io/react-native/docs/debugging.html#accessing-console-logs) isn't needed in CRNA (logs are forwarded alongside packager output)
  * [x] [Debugging: With Stetho](https://facebook.github.io/react-native/docs/debugging.html#debugging-with-stetho-http-facebook-github-io-stetho-on-android) requires native code
  * [x] [Debugging: Debugging Native Code](https://facebook.github.io/react-native/docs/debugging.html#debugging-native-code) is native-only
  * [x] [AppRegistry](https://facebook.github.io/react-native/docs/appregistry.html) only applies to ejected apps, since this is generated from code, I don't think we can set `banner: ejected`?
  * [x] [Linking](https://facebook.github.io/react-native/docs/linking.html) involves changing Android manifests and other native-side things
  * [x] [PermissionsAndroid](https://facebook.github.io/react-native/docs/permissionsandroid.html) may be flaky in the Expo client, I can't recall (cc jesseruder)
  * [x] [PushNotificationIOS](https://facebook.github.io/react-native/docs/pushnotificationios.html) won't work inside Expo, as it has to [handle its own push notifs](https://docs.expo.io/versions/v15.0.0/guides/push-notifications.html)
  * [x] [Geolocation](https://facebook.github.io/react-native/docs/geolocation.html) requires a polyfill that will most likely ship with next week's release, but that won't have any manifest changes necessary
* [ ] Figure out a strategy to handle the fact that CRNA will lag stable RN releases by ~1 week
* [x] Confirm linking out to CRNA docs is an OK strategy as opposed to moving ejecting, etc. docs in-tree
* [ ] Answer questions (I'll add some review comments to call out a few things)

</details>
Closes https://github.com/facebook/react-native/pull/13303

Differential Revision: D4950661

Pulled By: hramos

fbshipit-source-id: 3dd43828f38ca6ede3f2b0683608c56420dc6525
2017-04-26 07:16:18 -07:00
Bill 4344e064e7 Update Geolocation.js
Summary:
Clearer wording, on first read it is possible to get the impression that it will return immediately for both cached and on update request.
Closes https://github.com/facebook/react-native/pull/12072

Differential Revision: D4482784

Pulled By: mkonicek

fbshipit-source-id: 9eb9acf946b97b7b2b51f07e6a6572098afe7610
2017-01-31 11:58:30 -08:00
Héctor Ramos ab898ddda7 Set allowsBackgroundLocationUpdates as necessary when using location …
Summary:
Set the flag 'allowsBackgroundLocationUpdates' to YES if the location background mode is enabled and the 'Always Allow Location' key is set in the App Plist.

**motivation**

We found that on iOS 9.x, the allowsBackgroundLocationUpdates flag must be set on location manager in order to receive updates when the app is in the background (seems to affect actual device only).

**Test plan (required)**
Example app using the forked branch [here](https://github.com/briancalvium/react-native-geolocation-pr-example). Run this example through XCode on a device with 9.x, observe that location update logs continue to appear when the app is in the background. Switch to react native 0.32.0, observe that location update logs stop once the app is in the background.
Closes https://github.com/facebook/react-native/pull/9717

Differential Revision: D4167685

Pulled By: hramos

fbshipit-source-id: 5a62f8433bf8b553561a276fdaa544363298442a
2016-11-14 11:58:58 -08:00
Gant Laborde c6024f6391 - Add ability to detect if location was mocked
Summary:
Since API 18, Android locations have had the `isFromMockProvider()` function, to verify the validity of a provided location.  This was one of many methods one could verify location data, but as of Marshmallow, the other ways of detecting if "Mock Locations" is on in developer settings has been deprecated or defunct.

This means some devices can only detect location mocking by exposing the method on the location object.

This change provides that exposure.
Closes https://github.com/facebook/react-native/pull/9390

Differential Revision: D3858205

Pulled By: bestander

fbshipit-source-id: 3bae429cc0596ea01926c5be204f4403e4a2414f
2016-09-20 05:59:04 -07:00
Rob Hogan 384ebac28a Docs - explain how to access the geolocation API
Summary:
Explain that, unlike other APIs, geolocation follows the browser spec and is exposed through `navigator.geolocation` rather than as an `react-native` export.

This can be inferred from the example code but isn't otherwise stated in the docs. See also https://github.com/facebook/react-native/pull/9793
Closes https://github.com/facebook/react-native/pull/9810

Differential Revision: D3841341

Pulled By: javache

fbshipit-source-id: b1423e8bf7fb78c788f5cdc5630a4a948b8178c6
2016-09-09 05:43:35 -07:00
David Aurelio 94666f16c7 Auto-fix lint errors
Reviewed By: bestander

Differential Revision: D3683952

fbshipit-source-id: 9484d0b0e86859e8edaca0da1aa13a667f200905
2016-08-09 06:43:46 -07:00
Nick Lockwood b71db11554 Update RCTNetworking, RCTNetInfo and RCTLocationManager to use new events system
Summary: Updated networking and geolocation to use the new events system.

Reviewed By: bestander

Differential Revision: D3346129

fbshipit-source-id: 957716e54d7af8c4a6783f684098e92e92f19654
2016-05-25 04:28:36 -07:00
Konstantin Raev 2de0323182 Reverted commit D3339945
Summary: Updated networking and geolocation to use the new events system.

Reviewed By: javache

Differential Revision: D3339945

fbshipit-source-id: 01d307cf8a0aea3a404c87c6205132c42290abb1
2016-05-24 12:43:30 -07:00
Nick Lockwood 3f08fe4b7f Update RCTNetworking, RCTNetInfo and RCTLocationManager to use new events system
Summary: Updated networking and geolocation to use the new events system.

Reviewed By: javache

Differential Revision: D3339945

fbshipit-source-id: f1332fb2aab8560e4783739e223c1f31d583cfcf
2016-05-24 10:29:00 -07:00
Yao Bin Then 7e2026a268 Copy comment from LocationModule.java to Geolocation.js
Summary:This is to give a hint to developers when getCurrentPosition not returning anything on Android
Closes https://github.com/facebook/react-native/pull/6770

Differential Revision: D3131152

Pulled By: mkonicek

fb-gh-sync-id: 6726ed0f232c3b2f460d025fe9567e0d0783a707
fbshipit-source-id: 6726ed0f232c3b2f460d025fe9567e0d0783a707
2016-04-13 07:53:23 -07:00
David Aurelio ad8a335864 Remove knowledge of fbjs from the packager
Summary:Follow-up to https://github.com/facebook/react-native/pull/5084

This…
- changes all requires within RN to `require('fbjs/lib/…')`
- updates `.flowconfig`
- updates `packager/blacklist.js`
- adapts tests
- removes things from `Libraries/vendor/{core,emitter}` that are also in fbjs
- removes knowledge of `fbjs` from the packager

Closes https://github.com/facebook/react-native/pull/5084

Reviewed By: bestander

Differential Revision: D2926835

fb-gh-sync-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
shipit-source-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
2016-03-02 04:28:38 -08:00
Christopher Dro 109036b4c4 Expose option for distance filtering on location updates.
Summary:
My original implementation involved creating a `RCT_ENUM_CONVERTER` with `CLLocationAccuracy` on iOS and a Hashmap on Android that would convert `string` values to `doubles` for distance filtering.

I got this to work just fine but realized that I made things more complicated than they needed to be and simplified everything by just have the option be a decimal value (in meters) that works both for iOS and Android.

The only thing i'm not sure about is if we can set arbitrary values for CLLocationManager's distance filter.
nicklockwood  Any idea?
Closes https://github.com/facebook/react-native/pull/5563

Reviewed By: svcscm

Differential Revision: D2908250

Pulled By: nicklockwood

fb-gh-sync-id: d83c12b3ce7c343f413749a2cd614b3bf04d6750
2016-02-05 16:55:33 -08:00
sunnylqm 934f4de16e geolocation is now opensourced on android 2015-12-15 10:10:20 +08:00
Ricky Reusser 945a1c72db Note in docs that Android geolocation not yet open sourced 2015-11-20 15:43:07 -05:00
Martin Konicek 494930afb2 Open source the Android Location module
Reviewed By: foghina

Differential Revision: D2658581

fb-gh-sync-id: e95b21c5c7c06f3332d2a7c9fab8be9a2e6441cb
2015-11-18 10:15:21 -08:00
Spencer Ahrens 11b515b1b0 [ReactNative] clean lint in all of Libraries/ 2015-05-19 13:47:04 -08:00
Spencer Ahrens 68eb3e4906 [ReactNative] geolocation method docs 2015-04-24 16:26:28 -08:00
Felix Oghina d354c7dd91 [react_native] JS files from D2009062: add geolocation support 2015-04-24 02:24:18 -08:00