Commit Graph

82 Commits

Author SHA1 Message Date
Oli Barnett bbcb97a29a Location Services: don't reset desiredAccuracy on every update/error (#23209)
Summary:
See https://github.com/facebook/react-native/issues/7680.

On iOS the RCTLocationObserver delegate is overriding `desiredAccuracy` every time CLLocationManager calls `didUpdateLocations` or `didFailWithError`.  `desiredAccuracy` is reset to
`RCT_DEFAULT_LOCATION_ACCURACY` (100 meters) This effectively makes it impossible for a react-native app to use any location accuracy other than the default.

This commit simply removes the code which resets the desired accuracy, as there seems to be no rationale for doing so. The reset code was added as part of [a large general
change](705a8e0144) so the original intention is unclear from the history. If somebody can explain it to me, I'm happy to rework this PR accordingly.

Changelog:
----------
[iOS] [Fixed] - Location Services accuracy constantly reset to default of 100 meters.
Pull Request resolved: https://github.com/facebook/react-native/pull/23209

Differential Revision: D13879497

Pulled By: cpojer

fbshipit-source-id: f3c6c9c5ef698b23b99c407fd764ac990d69bf8c
2019-01-30 10:23:58 -08:00
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.

Reviewed By: yungsters

Differential Revision: D13195941

fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
2018-12-03 00:07:02 -08:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Pavlos Vinieratos 12410f3e4a Update Xcode projects (#19574)
Summary:
@public
A few people have been complaining, including me, that when we compile a react native project, there are a lot of warnings from xcode, suggesting to update the project build settings to the new recommendations.

I took the liberty to actually update the xcode projects, so we can finally have these gone, as well as replace some deprecated methods with the new suggested ones.

[IOS] [MINOR] [Xcode] - updated the Xcode projects with the latest suggestions from Xcode 9.3, and replaced a few deprecated methods of iOS with their new replacements.
Closes https://github.com/facebook/react-native/pull/19574

Reviewed By: shergin

Differential Revision: D8530135

Pulled By: hramos

fbshipit-source-id: b9c9ede0e07760cb2207caa6b468bd5c241848dc
2018-06-19 23:48:12 -07:00
Héctor Ramos aaddbee29e Revert D8489006: [react-native][PR] Update Xcode projects
Differential Revision:
D8489006

Original commit changeset: 2922b2e76aca

fbshipit-source-id: 84ba633b7e9a33b32e0a1347ebe6ca8bb1b02441
2018-06-18 12:18:02 -07:00
Pavlos Vinieratos 59b5743187 Update Xcode projects (#19574)
Summary:
A few people have been complaining, including me, that when we compile a react native project, there are a lot of warnings from xcode, suggesting to update the project build settings to the new recommendations.

I took the liberty to actually update the xcode projects, so we can finally have these gone, as well as replace some deprecated methods with the new suggested ones.

I made two react native projects, one with the regular react native and the other one using this branch.
Left is before, right is after:
![screen shot 2018-06-05 at 15 44 34](https://user-images.githubusercontent.com/100233/40979899-6aba12da-68d7-11e8-8630-6c3009b6dc24.png)

[IOS] [MINOR] [Xcode] - updated the Xcode projects with the latest suggestions from Xcode 9.3, and replaced a few deprecated methods of iOS with their new replacements.
Closes https://github.com/facebook/react-native/pull/19574

Differential Revision: D8489006

Pulled By: hramos

fbshipit-source-id: 2922b2e76aca6883c4f5d04e9c511b9fc1029583
2018-06-18 11:17:18 -07:00
Kevin Gozali f50df4f5ec iOS OSS: deployment target 8.0 => 9.0
Summary: Moving target deployment to iOS 9.0+ from now on, removing customization for iOS 8.

Reviewed By: shergin

Differential Revision: D8053439

fbshipit-source-id: 292c58f15c6e6caf8b28d15c1521812d6ed675c5
2018-05-22 01:16:45 -07:00
Eli White d01ab66b47 Prettier React Native Libraries
Reviewed By: sahrens

Differential Revision: D7961488

fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
2018-05-10 19:10:38 -07:00
Eli White 8f5ebe5952 Convert react-native-github/Libraries to let/const
Reviewed By: sahrens

Differential Revision: D7956042

fbshipit-source-id: 221851aa311f3cdd6326497352b366048db0a1bb
2018-05-10 16:16:35 -07:00
Rubén Norte d5e9e55fa3 Remove @providesModule from all modules
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.

It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)

* Checked the Flow configuration by running flow on the project root (no errors):

```
yarn flow
```

* Checked the Jest configuration by running the tests with a clean cache:

```
yarn jest --clearCache && yarn test
```

* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:

```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```

[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995

Reviewed By: mjesun

Differential Revision: D7729509

Pulled By: rubennorte

fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
2018-04-25 07:37:10 -07:00
Mats Byrkeland edb6ca72fd Fix ESLint warnings using 'yarn lint --fix'
Summary:
Hi! I would like to contribute to React Native, and I am just starting out. I forked the repo and found that it has quite a lot of ESLint warnings – many of which were automatically fixable. This PR is simply the result of running `yarn lint --fix` from the root folder.

Most changes are removing trailing spaces from comments.

Haven't really done any manual testing, since I haven't done any code changes manually. `yarn test` runs fine, `yarn flow` runs fine, `yarn prettier` is satisfied.

N/A

[INTERNAL][MINOR][] - Fix ESLint warnings
Closes https://github.com/facebook/react-native/pull/18047

Differential Revision: D7054948

Pulled By: hramos

fbshipit-source-id: d53e692698d1687de5821c3fb5cdb76a5e03b71e
2018-02-22 07:23:17 -08:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Héctor Ramos 28d60b68ad Trim docs that are already present in the open source docs site
Summary:
A lot of these docs are already present in https://github.com/facebook/react-native-website.
Closes https://github.com/facebook/react-native/pull/17776

Differential Revision: D6839783

Pulled By: hramos

fbshipit-source-id: 945fde22afb8f181d0463617d224d3f3429faa24
2018-01-29 16:20:15 -08:00
ngandhy 5c17db8352 re #17486 - set _locationManager if auth skipped
Summary:
This fixes #17486

make sure locationManager is being set before continuing.

Used if !locationManager vs else on previous statement as we should NEVER enter this code without _locationManager set. Also the else version might experience issues if someone touches the auth code and doesn't check this case, so seems more "long term stable".

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

This fixes #17486

1) Have a working geolocation demo
2) Add navigator.geolocation.setRNConfiguration({'skipPermissionRequests':true}); to your code. I added it to the constructor or componentWillMount for the app.
3) Observe that geolocation no longer works (times out)
4) Apply patch
5) Observe that geolocation works again

re #15096

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[IOS] [BUGFIX] [GeoLocation] - Fix skipPermissionRequests by setting _locationManager
Closes https://github.com/facebook/react-native/pull/17487

Differential Revision: D6718389

Pulled By: hramos

fbshipit-source-id: 08c1c9306b4d87cc40acdaa1550bb6df8345db02
2018-01-12 19:00:36 -08:00
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
Adlai Holler 0f440130b6 Standardize project indentation settings on 2 spaces
Summary:
Hi React Native folks! Love your work!

To make contributing easier, this sets the indentation settings of all the Xcode projects to 2 spaces to match their contents.
Closes https://github.com/facebook/react-native/pull/15275

Differential Revision: D5526462

Pulled By: javache

fbshipit-source-id: cbf0a8a87a1dbe31fceed2f0fffc53839cc06e59
2017-07-31 05:20:03 -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
Pieter De Baets 7c9173bc9e Enable -Wimplicit-retain-self en sync warning config for all projects
Summary:
This is enforced for all of our internal iOS code and a common cause of import failures.

cc janicduplessis
Closes https://github.com/facebook/react-native/pull/13124

Differential Revision: D4765016

fbshipit-source-id: 7c8248c98bca0fa6bad24d5a52b666243375e0db
2017-03-23 15:01:34 -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
Pieter De Baets 59407f3660 Redo exported headers and include paths for opensource
Summary:
Xcode really sucks, per some discussion on e1577df1fd and https://developer.apple.com/library/content/technotes/tn2215/_index.html, if you use the headers phase, and mark headers in your static library as public, they will actually end up in the final package that's built and you can't submit to the app store! This changes our xcode setup to use a copy files phase instead.

I've also changed the header include path to be $(BUILT_PRODUCTS_DIR)/include, which is added to the include path by Xcode by default, so 3rd party libraries should not be impacted by these changes anymore.

Reviewed By: mkonicek

Differential Revision: D4291607

fbshipit-source-id: 969b9ebcbeb8161f85427f8c429e198d9d0fae30
2016-12-07 15:28:29 -08:00
Pieter De Baets e1577df1fd Move all header imports to "<React/..>"
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.

Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".

Reviewed By: mmmulani

Differential Revision: D4213120

fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
2016-11-23 07:58:39 -08:00
Pieter De Baets 7c91f894ba Fix CSSLayout import hack, update podspec
Summary: Correct header import paths, update podspec so we point at the copy in ReactCommon (and can eventually remove the copy under React)

Reviewed By: astreet

Differential Revision: D4204501

fbshipit-source-id: e979a010092f025b2cdc289e1e5f22fc7b65a8d1
2016-11-21 09:13:36 -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
Rob Hogan 779f9e2b9c RCTLocationObserver: Fix reporting of timeout error
Summary:
Fixes an issue where location request timeout errors always reported "Unable to fetch location within **0s**".

Previously we had `@"Unable to fetch location within %zds.", (NSInteger)(timer.timeInterval * 1000.0)` but from the [NSTimer.timeInterval docs](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/#//apple_ref/occ/instp/NSTimer/timeInterval) "If the receiver is a non-repeating timer, returns 0 even if a time interval was set.".

Change to use `request.options.timeout` instead, which is a `Double` defaulting to `INFINITY`. Tested on an iOS simulator.
Closes https://github.com/facebook/react-native/pull/9888

Differential Revision: D3902788

Pulled By: javache

fbshipit-source-id: aef717d6c39f3177cb7056a17adc35c1bfd94132
2016-09-21 14:28:43 -07: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
Pieter De Baets 07553d0f1c Update React Native minimum OS version to iOS8
Reviewed By: majak

Differential Revision: D3723143

fbshipit-source-id: 482f9820370b752d937e6df7f74c33d53a0a2e7d
2016-09-01 19:43:47 -07:00
Martin Kralik ee49dd756d check for NSPhotoLibraryUsageDescription in plist
Reviewed By: javache

Differential Revision: D3723122

fbshipit-source-id: a5393c7dd3c36a15bec3f2e79859920419cc6726
2016-08-18 07:28:43 -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
Nick Lockwood d9737571c4 Updated AppState module to use new emitter system
Summary: AppState now subclasses NativeEventEmitter instead of using global RCTDeviceEventEmitter.

Reviewed By: javache

Differential Revision: D3310488

fbshipit-source-id: f0116599223f4411307385c0dab683659d8d63b6
2016-05-23 09:13:37 -07:00
Jean-Richard Lai 2310494f32 Fix distanceFilter caching for LocationObserver
Summary:
Allow changing distanceFilter after _locationManager has been initialized.

There is 2 reasons for this PR:
- When calling `getCurrentPosition`, `_observerOptions` is possibly not set properly ( as it is set only in `startObserving`), in this case it would have default values so `distanceFilter` will be 0 in this case ( which can be the right value but we should be more explicit about it, `kCLDistanceFilterNone` or `RCT_DEFAULT_LOCATION_ACCURACY`):
<img width="961" alt="screen shot 2016-04-14 at 8 44 09 pm" src="https://cloud.githubusercontent.com/assets/159813/14551465/6aa8791a-0288-11e6-9c98-1687357f8c2a.png">
- Another issue is that `distanceFilter` is cached so it can't be changed afterwards:

```javascript
let options;
options = {
  enableHighAccuracy: true,
  distanceFilter: 20,
};

this.watchId = this.geolocation.watchPosition(
  () => { },
  () => { },
  options,
);

// => sets distanceFilter to 20

this.geolocation.clearWatch(this.watchId);

options = {
  enableHighAccuracy:
Closes https://github.com/facebook/react-native/pull/6987

Differential Revision: D3258956

fb-gh-sync-id: 00a1d1b29d732a54cdc30e20a7a9a2de3dd9b725
fbshipit-source-id: 00a1d1b29d732a54cdc30e20a7a9a2de3dd9b725
2016-05-04 10:35:30 -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
realaboo 49b2805da2 Geolocation Accuracy and Cached Location Bug
Summary:There are two issues:

1. When calling startObserving or getCurrentPosition for the first time, _locationManager is not initialized and the accuracy value set in options is lost.

2. When using the cached location _lastLocationEvent, current timestamp retrieved by CFAbsoluteTimeGetCurrent() is from 2001, but the timestamp of the location is from 1970. In addition, the comparison between _lastLocationEvent[@"coords"][@"accuracy"] and options.accuracy is incorrect. Less value indicates more accurate location.
Closes https://github.com/facebook/react-native/pull/6198

Differential Revision: D3023786

Pulled By: nicklockwood

fb-gh-sync-id: 869c0e34252470275bf99cf0e5861747247f1158
shipit-source-id: 869c0e34252470275bf99cf0e5861747247f1158
2016-03-08 05:17:21 -08: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
Gašper Žnidaršič Bečaj 13f2aea85f Fix for different geolocation timestamp for Android and iOS
Summary:Geolocation timestamp is different for Android and iOs. For Android it is returning in UTC time in milliseconds since January 1, 1970, for iOS it was returned as time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001). Also for iOS time returned was "current system absolute time" and not the time at which this location was determined.

Tested with 0.21.0-rc React Native. Init project with this additional code:
`constructor(props) {super(props);
    navigator.geolocation.getCurrentPosition(
      (position) => {
        let initialPosition = JSON.stringify(position);
        console.log(position.timestamp);
      },
      (error) => alert(error.message),
      {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} );
  }
`

Tested with iOs simulator (iPhone 6S plus 9.2; iPhone 5s 8.4 )

sample result with change: 1456407795021.235
sample result without change: 23478100615007.884

Explaining links for iOS:
https://developer.apple.com/library/ios/do
Closes https://github.com/facebook/react-native/pull/6150

Differential Revision: D2976909

Pulled By: nicklockwood

fb-gh-sync-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a
shipit-source-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a
2016-02-25 07:23:33 -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
Sebastian Gronewold 6623e482b2 See issue #4886
Summary:
brentvatne this is the pull request you requested
See issue #4886

On iOS the plist key NSLocationAlwaysUsageDescription was ignored and the location could not be retreived when using this key. Now both keys NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription are supported. If NSLocationAlwaysUsageDescription is set, NSLocationWhenInUseUsageDescription will be simply ignored according to https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW18

I read the contribution guidelines regarding the Objective-C coding standards. Hopefully my line length breaks are okay - otherwise just give me a shout and I will fix that. Didn't write any line of Objective-C before so^^
Closes https://github.com/facebook/react-native/pull/5093

Reviewed By: svcscm

Differential Revision: D2823206

Pulled By: nicklockwood

fb-gh-sync-id: dd856a18416796749025e4b32d9c72895401916d
2016-01-12 03:11:31 -08:00
Marc Shilling f48dbbecd6 Fix getCurrentPosition
Summary:
Instantiates the _pendingRequests array before trying to add to it. As it currently stands, we try to add the pending request before the array is created. getCurrentPosition always fails on the first try.
Closes https://github.com/facebook/react-native/pull/4764

Reviewed By: svcscm

Differential Revision: D2764751

Pulled By: androidtrunkagent

fb-gh-sync-id: 411a03ff16d40725d8cc0909607632045eb5a27b
2015-12-16 08:37:33 -08:00
sunnylqm 934f4de16e geolocation is now opensourced on android 2015-12-15 10:10:20 +08:00
Nick Lockwood 060664fd3d Refactored module access to allow for lazy loading
Summary: public

The `bridge.modules` dictionary provides access to all native modules, but this API requires that every module is initialized in advance so that any module can be accessed.

This diff introduces a better API that will allow modules to be initialized lazily as they are needed, and deprecates `bridge.modules` (modules that use it will still work, but should be rewritten to use `bridge.moduleClasses` or `-[bridge moduleForName/Class:` instead.

The rules are now as follows:

* Any module that overrides `init` or `setBridge:` will be initialized on the main thread when the bridge is created
* Any module that implements `constantsToExport:` will be initialized later when the config is exported (the module itself will be initialized on a background queue, but  `constantsToExport:` will still be called on the main thread.
* All other modules will be initialized lazily when a method is first called on them.

These rules may seem slightly arcane, but they have the advantage of not violating any assumptions that may have been made by existing code - any module written under the original assumption that it would be initialized synchronously on the main thread when the bridge is created should still function exactly the same, but modules that avoid overriding `init` or `setBridge:` will now be loaded lazily.

I've rewritten most of the standard modules to take advantage of this new lazy loading, with the following results:

Out of the 65 modules included in UIExplorer:

* 16 are initialized on the main thread when the bridge is created
* A further 8 are initialized when the config is exported to JS
* The remaining 41 will be initialized lazily on-demand

Reviewed By: jspahrsummers

Differential Revision: D2677695

fb-gh-sync-id: 507ae7e9fd6b563e89292c7371767c978e928f33
2015-11-25 04:49:45 -08:00
Ricky Reusser 945a1c72db Note in docs that Android geolocation not yet open sourced 2015-11-20 15:43:07 -05:00