Skip to content

Commit 94365f2

Browse files
authored
Merge pull request #24 from GeoTecINIT/upgrade-ns-geolocation
Upgrade ns geolocation
2 parents ed416a8 + 100f941 commit 94365f2

File tree

16 files changed

+11220
-698
lines changed

16 files changed

+11220
-698
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ What we plan to offer in the future:
2222

2323
### Android only
2424

25+
#### Google Play Services conflicts
26+
2527
Given that we rely on [nativescript-geolocation](https://github.com/NativeScript/nativescript-geolocation) and use Google Play Services APIs for activity detection on Android devices, you might find Google Play Services version conflicts with other installed plugins.
2628

2729
In order to avoid them, we advise you to force a specific Google Play Services version. For a better human activity detection functionality, version 17 or above is highly recommended. In order to do so, please, indicate the Google Play Services Version number in your `app/App_Resources/Android/before-plugins.gradle` file (if the file does not exist, just create it):
@@ -36,6 +38,26 @@ android {
3638
}
3739
```
3840

41+
#### Permissions
42+
43+
In order to use geolocation on Android, you'll need to add the following permission(s) to your app's `AndroidManifest.xml` inside the `App_Resources/Android/src/main` dir:
44+
45+
```xml
46+
<!-- Always include this permission -->
47+
<!-- This permission is for "approximate" location data -->
48+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
49+
50+
<!-- Include only if your app benefits from precise location access. -->
51+
<!-- This permission is for "precise" location data -->
52+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
53+
54+
<!-- Required only when requesting background location access on
55+
Android 10 (API level 29) and higher. -->
56+
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
57+
```
58+
59+
More information can be found in the [Android docs here](https://developer.android.com/training/location/permissions).
60+
3961
> Source: [https://github.com/NativeScript/nativescript-geolocation](https://github.com/NativeScript/nativescript-geolocation)
4062
4163
## Installation
@@ -45,7 +67,7 @@ Run the following command in your project's root folder.
4567
NS7+:
4668

4769
```javascript
48-
tns plugin add nativescript-context-apis
70+
ns plugin add nativescript-context-apis
4971
```
5072

5173
NS6:

azure-pipelines.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ pool:
1515
steps:
1616
- task: NodeTool@0
1717
inputs:
18-
versionSpec: '10.x'
18+
versionSpec: '16.x'
1919
displayName: 'Install Node.js'
2020

21+
- task: JavaToolInstaller@0
22+
inputs:
23+
versionSpec: '11'
24+
jdkArchitectureOption: 'x64'
25+
jdkSourceOption: 'PreInstalled'
26+
2127
- script: |
22-
echo no | npm install -g nativescript@7
23-
tns usage-reporting disable
24-
tns error-reporting disable
28+
echo no | npm install -g nativescript
29+
ns usage-reporting disable
30+
ns error-reporting disable
2531
displayName: 'Install NativeScript CLI'
2632

2733
- script: |
@@ -33,13 +39,13 @@ steps:
3339
- script: |
3440
cd demo
3541
npm install
36-
tns build android --bundle --env.uglify --env.snapshot
42+
ns build android --bundle --env.uglify --env.snapshot
3743
displayName: 'Build'
3844

3945
- script: |
4046
./ci-tools/wait-for-emulator.sh
4147
cd demo
42-
tns test android --watch false --justlaunch
48+
ns test android --watch false --justlaunch
4349
displayName: 'Test'
4450

4551
- task: PublishTestResults@2

ci-tools/wait-for-emulator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env bash
22

33
# Install AVD files
4-
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;google_apis;x86'
4+
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-30;google_apis;x86'
55

66
# Create emulator
7-
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-27;google_apis;x86' --force
7+
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-30;google_apis;x86' --force
88

99
$ANDROID_HOME/emulator/emulator -list-avds
1010

demo/app/App_Resources/Android/app.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
android {
1313
// todo: remove once ndk 23+ is supported
1414
ndkVersion "22.1.7171670"
15+
compileSdkVersion 30
1516
defaultConfig {
1617
minSdkVersion 19
18+
targetSdkVersion 30
1719
generatedDensities = []
1820
}
1921
aaptOptions {

demo/app/App_Resources/Android/src/main/AndroidManifest.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
android:largeScreens="true"
1111
android:xlargeScreens="true"/>
1212

13+
<!-- Always include this permission -->
14+
<!-- This permission is for "approximate" location data -->
15+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
16+
17+
<!-- Include only if your app benefits from precise location access. -->
18+
<!-- This permission is for "precise" location data -->
19+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
20+
21+
<!-- Required only when requesting background location access on
22+
Android 10 (API level 29) and higher. -->
23+
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
24+
1325
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
1426
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
1527
<uses-permission android:name="android.permission.INTERNET"/>

0 commit comments

Comments
 (0)