forked from NativeScript/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
62 lines (52 loc) · 1.4 KB
/
main.ts
File metadata and controls
62 lines (52 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
In NativeScript, the app.ts file is the entry point to your application.
You can use this file to perform app-level initialization, but the primary
purpose of the file is to pass control to the app’s first module.
*/
import {
Application,
Frame
} from '@nativescript/core'
import './deeplinks'
import { openDemo } from './utils/demo'
import { disableDemoMode, enableDemoMode } from './utils/demoMode'
Application.on('deeplink', (args: any) => {
console.log('Got a deeplink: ' + args.url)
const [, actionFull] = args.url.split('://')
const [action, ...actionArgs] = actionFull.split('/')
console.log('Action: ' + action)
console.log('Action args: ' + actionArgs)
let handled = true
switch (action) {
case 'enableDemoMode': {
enableDemoMode()
break
}
case 'disableDemoMode': {
disableDemoMode()
break
}
case 'navigate': {
// ./ui/ActivityIndicator/template.xml
const path = actionArgs.join('/')
openDemo(path);
}
case 'navigateBack': {
const frame = Application.getRootView() as Frame
if (frame.canGoBack()) {
frame.goBack()
}
}
default: {
handled = false
break
}
}
args.handled = handled
})
// Application.iOSApplication.delegate =
Application.run({ moduleName: 'app-root' })
/*
Do not place any code after the application has been started as it will not
be executed on iOS.
*/