apps-sdk 1.0.19 → 1.0.20
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/index.js +3 -2
- package/package.json +1 -1
- package/src/libraries/Storage.js +9 -3
- package/src/libraries/Utils.js +12 -0
- package/src/libraries/index.js +1 -0
- package/types/index.d.ts +4 -0
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {NotificationsPush, Networking, Storage, Session} from "./src/libraries";
|
|
1
|
+
import {NotificationsPush, Networking, Storage, Session, Utils} from "./src/libraries";
|
|
2
2
|
|
|
3
3
|
class AppsSDK {
|
|
4
4
|
initializePushNotifications = async() => {
|
|
@@ -16,5 +16,6 @@ export default {
|
|
|
16
16
|
initializePushNotifications: Core.initializePushNotifications,
|
|
17
17
|
networking: Networking,
|
|
18
18
|
storage: Storage,
|
|
19
|
-
session: Session
|
|
19
|
+
session: Session,
|
|
20
|
+
utils: Utils
|
|
20
21
|
}
|
package/package.json
CHANGED
package/src/libraries/Storage.js
CHANGED
|
@@ -2,6 +2,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
|
2
2
|
import * as MediaLibrary from 'expo-media-library';
|
|
3
3
|
import * as FileSystem from 'expo-file-system';
|
|
4
4
|
import * as Sharing from 'expo-sharing';
|
|
5
|
+
import utils from "./Utils";
|
|
5
6
|
|
|
6
7
|
class Storage {
|
|
7
8
|
async storeData(key, value) {
|
|
@@ -48,9 +49,14 @@ class Storage {
|
|
|
48
49
|
async handleDownloadImage(url, fileName) {
|
|
49
50
|
const { status } = await MediaLibrary.requestPermissionsAsync();
|
|
50
51
|
if (status === 'granted') {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
let fileUri = FileSystem.documentDirectory + fileName;
|
|
53
|
+
if (utils.isBase64(url)) {
|
|
54
|
+
await FileSystem.writeAsStringAsync(fileUri, url, { encoding: FileSystem.EncodingType.Base64 });
|
|
55
|
+
} else {
|
|
56
|
+
const { uri: localUri } = await FileSystem.downloadAsync(url, fileUri);
|
|
57
|
+
fileUri = localUri;
|
|
58
|
+
}
|
|
59
|
+
const asset = await MediaLibrary.createAssetAsync(fileUri);
|
|
54
60
|
const albums = await MediaLibrary.getAlbumsAsync();
|
|
55
61
|
let album = albums.find(a => a.title === 'Camera' || a.title === 'Camera Roll' || a.title === 'Pictures');
|
|
56
62
|
if (album) {
|
package/src/libraries/index.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ declare module 'apps-sdk' {
|
|
|
67
67
|
handleShareFile(url: string, filename: string): Promise<void>;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
export class Utils {
|
|
71
|
+
isBase64(str: string): boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
export class NotificationsPush {
|
|
71
75
|
initialize(): Promise<void>;
|
|
72
76
|
registerForPushNotificationsAsync(): Promise<string>;
|