apps-sdk 1.0.16 → 1.0.18
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 +2 -1
- package/src/libraries/Networking.js +2 -1
- package/src/libraries/Storage.js +24 -0
- 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.18",
|
|
4
4
|
"description": "Apps SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"expo-constants": "^15.4.5",
|
|
15
15
|
"expo-device": "^5.9.3",
|
|
16
16
|
"expo-localization": "^14.8.3",
|
|
17
|
+
"expo-media-library": "^15.9.1",
|
|
17
18
|
"expo-notifications": "^0.23.0",
|
|
18
19
|
"react-native": "^0.73.2"
|
|
19
20
|
},
|
|
@@ -134,12 +134,13 @@ class Networking {
|
|
|
134
134
|
|
|
135
135
|
setEndpoints(domains) {
|
|
136
136
|
domains.contents && (config.ENDPOINTS.CONTENTS = domains.contents);
|
|
137
|
+
storage.storeData("ENDPOINTS", config.ENDPOINTS);
|
|
137
138
|
// domains.audiences && (config.ENDPOINTS.SET_ATTRIBUTION = domains.audiences);
|
|
138
139
|
// domains.notification_token && (config.ENDPOINTS.NOTIFICATION_TOKEN = domains.notification_token);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
getEndpoints() {
|
|
142
|
-
return
|
|
143
|
+
return storage.getData("ENDPOINTS");
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
setEvents(events) {
|
package/src/libraries/Storage.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2
|
+
import * as MediaLibrary from 'expo-media-library';
|
|
2
3
|
|
|
3
4
|
class Storage {
|
|
4
5
|
async storeData(key, value) {
|
|
@@ -41,6 +42,29 @@ class Storage {
|
|
|
41
42
|
console.error('Error fetching data from AsyncStorage:', error);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
async handleDownloadImage(url) {
|
|
47
|
+
const { status } = await MediaLibrary.requestPermissionsAsync();
|
|
48
|
+
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
|
+
const fileUri = FileSystem.documentDirectory + fileName;
|
|
55
|
+
const { uri: localUri } = await FileSystem.downloadAsync(url, fileUri);
|
|
56
|
+
const asset = await MediaLibrary.createAssetAsync(localUri);
|
|
57
|
+
const albums = await MediaLibrary.getAlbumsAsync();
|
|
58
|
+
let album = albums.find(a => a.title === 'Camera' || a.title === 'Camera Roll' || a.title === 'Pictures');
|
|
59
|
+
if (album) {
|
|
60
|
+
await MediaLibrary.addAssetsToAlbumAsync([asset], album, false);
|
|
61
|
+
} else {
|
|
62
|
+
album = await MediaLibrary.createAlbumAsync('Descargas', asset, false);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
console.log('Permiso de galería denegado');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
export default new Storage();
|
package/types/index.d.ts
CHANGED