Skip to content

Commit 05ecfd8

Browse files
authored
Merge pull request #11 from GeoTecINIT/NS7Migration
Ns7 Support
2 parents 653a41e + add9060 commit 05ecfd8

File tree

23 files changed

+3050
-2881
lines changed

23 files changed

+3050
-2881
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ android {
4040
4141
## Installation
4242

43-
Run the following command in your project's root folder:
43+
Run the following command in your project's root folder.
44+
45+
NS7+:
4446

4547
```javascript
4648
tns plugin add nativescript-context-apis
4749
```
4850

51+
NS6:
52+
```javascript
53+
tns plugin add nativescript-context-apis@1.0.3
54+
```
55+
4956
(Optional) You'll need RxJS also to properly work with geolocation streams
5057

5158
```javascript

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trigger:
77
- v*
88
pr:
99
- master
10-
10+
1111

1212
pool:
1313
vmImage: 'macos-latest'
@@ -19,7 +19,7 @@ steps:
1919
displayName: 'Install Node.js'
2020

2121
- script: |
22-
echo no | npm install -g nativescript@6.8.0
22+
echo no | npm install -g nativescript@7
2323
tns usage-reporting disable
2424
tns error-reporting disable
2525
displayName: 'Install NativeScript CLI'

demo/app/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as app from "tns-core-modules/application";
1+
import { Application } from "@nativescript/core";
22
import { contextApis } from "nativescript-context-apis";
33

44
contextApis.init();
55

6-
app.run({ moduleName: "app-root" });
6+
Application.run({ moduleName: "app-root" });
77

88
/*
99
Do not place any code after the application has been started as it will not

demo/app/home/home-page.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ a code-behind file. The code-behind is a great place to place your view
44
logic, and to set up your page’s data binding.
55
*/
66

7-
import { NavigatedData, Page } from "tns-core-modules/ui/page";
8-
import {
9-
on,
10-
resumeEvent,
11-
suspendEvent,
12-
} from "tns-core-modules/application/application";
7+
import { NavigatedData, Page, Application } from "@nativescript/core";
138

149
import { HomeViewModel } from "./home-view-model";
1510

@@ -31,7 +26,7 @@ export function onNavigatingTo(args: NavigatedData) {
3126

3227
let locationSubscription: Subscription;
3328

34-
on(resumeEvent, () => {
29+
Application.on(Application.resumeEvent, () => {
3530
if (!_preparing) {
3631
printCurrentLocation().catch((err) => {
3732
console.error(`Could not print current location: ${err}`);
@@ -46,7 +41,7 @@ export function onNavigatingTo(args: NavigatedData) {
4641
listenToActivityChanges();
4742
});
4843

49-
on(suspendEvent, () => {
44+
Application.on(Application.suspendEvent, () => {
5045
if (locationSubscription) {
5146
locationSubscription.unsubscribe();
5247
}

demo/app/home/home-view-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Observable } from "tns-core-modules/data/observable";
1+
import { Observable } from "@nativescript/core";
22

33
export class HomeViewModel extends Observable {
44
constructor() {

demo/app/tests/internal/activity-recognition/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { android as androidApp } from "tns-core-modules/application/application";
1+
import { Application } from "@nativescript/core";
22
import {
33
getActivityRecognizer,
44
Resolution,
@@ -9,7 +9,7 @@ import { AndroidMediumResRecognizer } from "nativescript-context-apis/internal/a
99
describe("Activity recognition module", () => {
1010
it("returns a low res recognizer when asked", () => {
1111
const lowResRecognizer = getActivityRecognizer(Resolution.LOW);
12-
if (androidApp) {
12+
if (Application.android) {
1313
expect(lowResRecognizer).toBeInstanceOf(AndroidLowResRecognizer);
1414
} else {
1515
expect(lowResRecognizer).not.toBeNull();
@@ -18,7 +18,7 @@ describe("Activity recognition module", () => {
1818

1919
it("returns a medium res recognizer when asked", () => {
2020
const mediumResRecognizer = getActivityRecognizer(Resolution.MEDIUM);
21-
if (androidApp) {
21+
if (Application.android) {
2222
expect(mediumResRecognizer).toBeInstanceOf(
2323
AndroidMediumResRecognizer
2424
);

demo/app/tests/internal/geolocation/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe("Geolocation provider", () => {
126126
onChange(locations[i]);
127127
i++;
128128
});
129-
return intervalId;
129+
return (intervalId as unknown) as number;
130130
});
131131
spyOn(adapter, "stopListening").and.callFake((listenerId) => {
132132
clearInterval(listenerId);

demo/nativescript.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NativeScriptConfig } from '@nativescript/core';
2+
3+
export default {
4+
id: 'org.nativescript.demo',
5+
main: './app/app.js',
6+
appResourcesPath: './app/App_Resources',
7+
webpackConfigPath: 'webpack.config.js',
8+
ios: {
9+
discardUncaughtJsExceptions: true
10+
},
11+
android: {
12+
discardUncaughtJsExceptions: true,
13+
v8Flags: '--nolazy --expose_gc',
14+
"markingMode": "none",
15+
"suppressCallJSMethodExceptions": false
16+
}
17+
} as NativeScriptConfig;

0 commit comments

Comments
 (0)