Skip to content

Commit

Permalink
Merge pull request rn-bridge#4 from rn-bridge/release-0.8.0
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
sriharshamadamanchi authored Aug 21, 2024
2 parents ef8fe56 + 8e37744 commit c188d59
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 190 deletions.
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.1.cjs
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ Your `AndroidManifest.xml` should look liks this

### requestLocation
```javascript
import { requestLocation } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await requestLocation({ allowWhileUsing: true });
const response = await Geofencing.requestLocation({ allowWhileUsing: true });
```
Response:
```json
Expand All @@ -121,9 +121,9 @@ Response:

To request background location:
```javascript
import { requestLocation } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await requestLocation({ allowAlways: true });
const response = await Geofencing.requestLocation({ allowAlways: true });
```
Response:
```json
Expand All @@ -141,17 +141,17 @@ Supported options:
### getLocationAuthorizationStatus
```javascript
import { getLocationAuthorizationStatus } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await getLocationAuthorizationStatus();
const response = await Geofencing.getLocationAuthorizationStatus();
```
Response: `WhileInUse` `Always` `Denied`

### getCurrentLocation
```javascript
import { getCurrentLocation } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await getCurrentLocation();
const response = await Geofencing.getCurrentLocation();
```
Reponse:
```json
Expand All @@ -171,9 +171,9 @@ Reponse:

### addGeofence
```javascript
import { addGeofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await addGeofence({
const response = await Geofencing.addGeofence({
id: 'a9957259-8036-4dcb-974c-34eae9b44bdb',
latitude: 16.153062,
longitude: 100.281585,
Expand All @@ -195,9 +195,9 @@ Supported options:

### removeGeofence
```javascript
import { removeGeofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await removeGeofence(id)
const response = await Geofencing.removeGeofence(id)
```
Response:
```json
Expand All @@ -211,9 +211,9 @@ Supported options:

### getRegisteredGeofences
```javascript
import { getRegisteredGeofences } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const response = await getRegisteredGeofences()
const response = await Geofencing.getRegisteredGeofences()
```
Response:
```json
Expand Down Expand Up @@ -250,9 +250,9 @@ import { Authorization } from '@rn-bridge/react-native-geofencing';
### onEnter
```javascript
import { Geofence, Events } from '@rn-bridge/react-native-geofencing';
import Geofencing, { Events } from '@rn-bridge/react-native-geofencing';

Geofence.onEnter((ids: string[]) => {
Geofencing.onEnter((ids: string[]) => {
console.log(Events.Enter, ids);
});
```
Expand All @@ -263,9 +263,9 @@ Response:

### onExit
```javascript
import { Geofence, Events } from '@rn-bridge/react-native-geofencing';
import Geofencing, { Events } from '@rn-bridge/react-native-geofencing';

Geofence.onExit((ids: string[]) => {
Geofencing.onExit((ids: string[]) => {
console.log(Events.Exit, ids);
});
```
Expand All @@ -276,30 +276,30 @@ Response:

### removeOnEnterListener
```javascript
import { Geofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

Geofence.removeOnEnterListener()
Geofencing.removeOnEnterListener()
```

### removeOnExitListener
```javascript
import { Geofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

Geofence.removeOnExitListener()
Geofencing.removeOnExitListener()
```

### isOnEnterListenerAdded
```javascript
import { Geofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

Geofence.isOnEnterListenerAdded() // true or false
Geofencing.isOnEnterListenerAdded() // true or false
```

### isOnExitListenerAdded
```javascript
import { Geofence } from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

Geofence.isOnExitListenerAdded() // true or false
Geofencing.isOnExitListenerAdded() // true or false
```

## How To Run Example App ?
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.android.Version

buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ReactNativeGeofencing_kotlinVersion"]
def kotlin_version = project.properties["ReactNativeGeofencing_kotlinVersion"]

repositories {
google()
Expand Down
6 changes: 3 additions & 3 deletions example/index.ts → example/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AppRegistry } from 'react-native';
import { App } from './src/App';
import { name as appName } from './app.json';
import { Geofence, Events } from '@rn-bridge/react-native-geofencing';
import Geofencing, { Events } from '@rn-bridge/react-native-geofencing';

Geofence.onEnter((ids: string[]) => {
Geofencing.onEnter((ids) => {
console.log(Events.Enter, ids);
});

Geofence.onExit((ids: string[]) => {
Geofencing.onExit((ids) => {
console.log(Events.Exit, ids);
});

Expand Down
23 changes: 8 additions & 15 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { StyleSheet, View, TouchableOpacity, Text, Alert } from 'react-native';
import {
addGeofence,
removeGeofence,
getRegisteredGeofences,
requestLocation,
getLocationAuthorizationStatus,
getCurrentLocation
} from '@rn-bridge/react-native-geofencing';
import Geofencing from '@rn-bridge/react-native-geofencing';

const Button = ({
title,
Expand Down Expand Up @@ -34,7 +27,7 @@ export const App = () => {
style={styles.button}
title="Request Location While Using"
onPress={async () => {
const response = await requestLocation({ allowWhileUsing: true });
const response = await Geofencing.requestLocation({ allowWhileUsing: true });
console.log('requestLocation:', response);
Alert.alert('', `Location: ${response.location}`);
}}
Expand All @@ -45,7 +38,7 @@ export const App = () => {
style={styles.button}
title="Request Location Always"
onPress={async () => {
const response = await requestLocation({ allowAlways: true });
const response = await Geofencing.requestLocation({ allowAlways: true });
console.log('requestLocation:', response);
Alert.alert('', `Location: ${response.location}`);
}}
Expand All @@ -56,7 +49,7 @@ export const App = () => {
style={styles.button}
title="Get Current Location"
onPress={async () => {
const response = await getCurrentLocation();
const response = await Geofencing.getCurrentLocation();
console.log('getCurrentLocation:', response);
Alert.alert(
'',
Expand All @@ -70,7 +63,7 @@ export const App = () => {
style={styles.button}
title="Add Geo Fence"
onPress={async () => {
const response = await addGeofence({
const response = await Geofencing.addGeofence({
id: 'a9957259-8036-4dcb-974c-34eae9b44bdb',
latitude: 10.9314,
longitude: 76.9781,
Expand All @@ -92,7 +85,7 @@ export const App = () => {
style={styles.button}
title="Remove Geo Fence"
onPress={async () => {
const response = await removeGeofence(
const response = await Geofencing.removeGeofence(
'a9957259-8036-4dcb-974c-34eae9b44bdb'
);

Expand All @@ -111,7 +104,7 @@ export const App = () => {
style={styles.button}
title="Get Registered Geo Fences"
onPress={async () => {
const response = await getRegisteredGeofences();
const response = await Geofencing.getRegisteredGeofences();
console.log('getRegisteredGeofences:', response);
const ids = response.map((id: string, index: number) => `id${index+1}: ${id}`).join("\n")
const message = response.length == 0 ? "No geofence registered" : ids
Expand All @@ -124,7 +117,7 @@ export const App = () => {
style={styles.button}
title="Get Authorization Status"
onPress={async () => {
const response = await getLocationAuthorizationStatus();
const response = await Geofencing.getLocationAuthorizationStatus();
console.log('getLocationAuthorizationStatus:', response);
Alert.alert('', `Location: ${response}`);
}}
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@rn-bridge/react-native-geofencing",
"version": "0.7.0",
"version": "0.8.0",
"description": "Native modules to determine if a location is within defined geographical boundaries",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
"main": "./src/index.tsx",
"module": "./lib/module/index.js",
"types": "./src/types/index.d.ts",
"files": [
Expand Down Expand Up @@ -114,6 +114,13 @@
{
"esm": true
}
],
[
"typescript",
{
"project": "tsconfig.build.json",
"esm": true
}
]
]
}
Expand Down
Loading

0 comments on commit c188d59

Please sign in to comment.