apps-sdk 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/libraries/Storage.js +13 -6
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apps-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Apps SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
"crypto-es": "^2.1.0",
|
|
14
14
|
"expo-constants": "^15.4.5",
|
|
15
15
|
"expo-device": "^5.9.3",
|
|
16
|
+
"expo-file-system": "^16.0.6",
|
|
16
17
|
"expo-localization": "^14.8.3",
|
|
17
18
|
"expo-media-library": "^15.9.1",
|
|
18
19
|
"expo-notifications": "^0.23.0",
|
|
20
|
+
"expo-sharing": "^11.10.0",
|
|
19
21
|
"react-native": "^0.73.2"
|
|
20
22
|
},
|
|
21
23
|
"types": "./types/index.d.ts"
|
package/src/libraries/Storage.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2
2
|
import * as MediaLibrary from 'expo-media-library';
|
|
3
|
+
import * as FileSystem from 'expo-file-system';
|
|
4
|
+
import * as Sharing from 'expo-sharing';
|
|
3
5
|
|
|
4
6
|
class Storage {
|
|
5
7
|
async storeData(key, value) {
|
|
@@ -43,14 +45,9 @@ class Storage {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
async handleDownloadImage(url) {
|
|
48
|
+
async handleDownloadImage(url, fileName) {
|
|
47
49
|
const { status } = await MediaLibrary.requestPermissionsAsync();
|
|
48
50
|
if (status === 'granted') {
|
|
49
|
-
const parsedUrl = new URL(url);
|
|
50
|
-
let fileName = parsedUrl.pathname.split('/').pop();
|
|
51
|
-
if (parsedUrl.searchParams.has('f')) {
|
|
52
|
-
fileName = decodeURIComponent(parsedUrl.searchParams.get('f')).split('/').pop();
|
|
53
|
-
}
|
|
54
51
|
const fileUri = FileSystem.documentDirectory + fileName;
|
|
55
52
|
const { uri: localUri } = await FileSystem.downloadAsync(url, fileUri);
|
|
56
53
|
const asset = await MediaLibrary.createAssetAsync(localUri);
|
|
@@ -65,6 +62,16 @@ class Storage {
|
|
|
65
62
|
console.log('Permiso de galería denegado');
|
|
66
63
|
}
|
|
67
64
|
}
|
|
65
|
+
|
|
66
|
+
async handleShareFile(url, fileName) {
|
|
67
|
+
const fileUri = FileSystem.documentDirectory + fileName;
|
|
68
|
+
const { uri: localUri } = await FileSystem.downloadAsync(url, fileUri);
|
|
69
|
+
if (!(await Sharing.isAvailableAsync())) {
|
|
70
|
+
alert('Compartir no está disponible en tu plataforma.');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await Sharing.shareAsync(localUri);
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
export default new Storage();
|
package/types/index.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ declare module 'apps-sdk' {
|
|
|
64
64
|
printAllKeys(): Promise<void>;
|
|
65
65
|
removeData(key: string): Promise<void>;
|
|
66
66
|
handleDownloadImage(url: string, filename: string): Promise<void>;
|
|
67
|
+
handleShareFile(url: string, filename: string): Promise<void>;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
export class NotificationsPush {
|