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
|
import { Application, Frame, Http, Observable, Utils } from '@nativescript/core';
import * as permissions from '@nativescript-community/perms';
export class LoginModel extends Observable {
public server: string = 'http://192.168.178.59:8080';
public username: string;
public password: string;
constructor() {
super();
}
async onLogin() {
const content = new FormData();
content.append('username', this.username);
content.append('password', this.password);
const response = await Http.request({
url: this.server,
method: 'POST',
content: content,
});
console.log(response.content?.toString());
console.log(
Application.android.foregroundActivity.requestPermissions([
android.Manifest.permission.READ_EXTERNAL_STORAGE,
], 3765)
);
console.log(
Application.android.foregroundActivity.shouldShowRequestPermissionRationale(android.Manifest.permission.READ_EXTERNAL_STORAGE)
);
console.log(
Utils.android.getApplicationContext().checkPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE, android.os.Process.myPid(), android.os.Process.myUid())
);
console.log(
permissions.request({
storage: { read: true, write: false },
photo: { reason: 'to pick images' },
})
);
}
goToGalleries() {
const frame = Frame.topmost();
frame.navigate('gallery-page');
}
}
|