apps-sdk 1.0.52 → 1.0.53

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -51,11 +51,8 @@ class Networking {
51
51
  async setToken(token) {
52
52
  try {
53
53
  const installID = await storage.getData('install_id');
54
- const response = await fetch(config.ENDPOINTS.EVENTS_PUSH.replace('[TOKEN]', token).replace('[INSTALL_ID]', installID));
55
- const json = await response.json();
56
- if(json.success){
57
- return true;
58
- }
54
+ const result = this.request(config.ENDPOINTS.NOTIFICATION_SET_TOKEN, { expo_id: token });
55
+ console.log('setToken result: ', result);
59
56
  } catch (error) {
60
57
  console.error(error);
61
58
  return null;
@@ -4,8 +4,10 @@ import * as FileSystem from 'expo-file-system';
4
4
  import * as Sharing from 'expo-sharing';
5
5
  import Networking from "./Networking";
6
6
  import utils from "./Utils";
7
+ import * as config from "../../config";
7
8
 
8
9
  const CREATIONS_DIR = `${FileSystem.documentDirectory}/creations`
10
+ const TMP_DIR = `${FileSystem.documentDirectory}/tmp`
9
11
 
10
12
  class Storage {
11
13
  async storeData(key, value) {
@@ -112,7 +114,7 @@ class Storage {
112
114
  try {
113
115
  const directoryUri = CREATIONS_DIR + '/' + fileName;
114
116
  console.log('handleDownloadImageToCreations directoryUri:', directoryUri);
115
- await this.createCreationsDir(directoryUri);
117
+ await this.createDir(directoryUri);
116
118
  const fileUri = directoryUri + '/image.jpg';
117
119
  console.log('handleDownloadImageToCreations fileUri:', fileUri);
118
120
  const fileData = directoryUri + '/data.json';
@@ -127,6 +129,22 @@ class Storage {
127
129
  }
128
130
  }
129
131
 
132
+ async handleDownloadImageToTMP(base64Image, fileName) {
133
+ try {
134
+ const directoryUri = TMP_DIR + '/' + fileName;
135
+ console.log('handleDownloadImageToTMP directoryUri:', directoryUri);
136
+ await this.createDir(directoryUri);
137
+ const fileUri = directoryUri + '/image.jpg';
138
+ console.log('handleDownloadImageToTMP fileUri:', fileUri);
139
+ console.log('handleDownloadImageToTMP base64Image:', base64Image.substring(0, 50) + '...');
140
+ const base64Data = base64Image.replace(/^data:image\/[a-z]+;base64,/, '');
141
+ await FileSystem.writeAsStringAsync(fileUri, base64Data, { encoding: FileSystem.EncodingType.Base64,})
142
+ return fileUri;
143
+ } catch (error) {
144
+ console.error('Error al guardar la imagen en FileSystem TMP:', error);
145
+ }
146
+ }
147
+
130
148
  async handleDownloadImageToGallery(imageURI) {
131
149
  try {
132
150
  const { status } = await MediaLibrary.requestPermissionsAsync();
@@ -143,7 +161,7 @@ class Storage {
143
161
  try {
144
162
  const info = await FileSystem.getInfoAsync(CREATIONS_DIR);
145
163
  if (!info.exists) {
146
- await this.createCreationsDir(CREATIONS_DIR);
164
+ await this.createDir(CREATIONS_DIR);
147
165
  return [];
148
166
  }
149
167
 
@@ -204,10 +222,10 @@ class Storage {
204
222
  }
205
223
  };
206
224
 
207
- async createCreationsDir (dirName) {
225
+ async createDir (dirName) {
208
226
  const directory = await FileSystem.getInfoAsync(dirName)
209
227
  if (!directory.exists) {
210
- console.log('createCreationsDir', dirName);
228
+ console.log('Creating Directory', dirName);
211
229
  await FileSystem.makeDirectoryAsync(dirName, { intermediates: true })
212
230
  const newDirectory = await FileSystem.getInfoAsync(dirName)
213
231
  }
@@ -220,6 +238,10 @@ class Storage {
220
238
  }
221
239
  return await Sharing.shareAsync(fileName);
222
240
  }
241
+
242
+ setTrackingPermissionGranted(value) {
243
+ config.TRACKING_ACTIVE = value;
244
+ }
223
245
  }
224
246
 
225
247
  export default new Storage();
package/types/index.d.ts CHANGED
@@ -68,13 +68,15 @@ declare module 'apps-sdk' {
68
68
  removeData(key: string): Promise<void>;
69
69
  handleDownloadImage(url: string, filename: string): Promise<void>;
70
70
  handleShareFile(filename: string): Promise<boolean>;
71
- createCreationsDir(dirName: string): Promise<void>;
71
+ createDir(dirName: string): Promise<void>;
72
72
  handleDownloadImageToCreations(base64Image: string, fileName: string, data: object): Promise<{ directoryUri: string, fileUri: string, fileData: any }>;
73
+ handleDownloadImageToTMP(base64Image: string, fileName: string): Promise<string>;
73
74
  getCreations(): Promise<any>;
74
75
  deleteCreation(dirName: string): Promise<void>;
75
76
  deleteAllCreations(): Promise<void>;
76
77
  handleDownloadImageToGallery(imageURI: string): Promise<void>;
77
78
  handleRequestGalleryPermission(): Promise<string>;
79
+ setTrackingPermissionGranted(value: boolean): void;
78
80
  }
79
81
 
80
82
  export class Utils {