@boneframework/native-components 1.0.17 → 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/components/{ApiInterceptor.js → ApiInterceptor.tsx} +1 -1
- package/components/{Image.js → Image.tsx} +1 -5
- package/hooks/useNotifications.ts +44 -0
- package/package.json +4 -1
- /package/components/{ActivityIndicator.js → ActivityIndicator.tsx} +0 -0
- /package/components/{Animation.js → Animation.tsx} +0 -0
- /package/components/{Button.js → Button.tsx} +0 -0
- /package/components/{Card.js → Card.tsx} +0 -0
- /package/components/{CategoryPickerItem.js → CategoryPickerItem.tsx} +0 -0
- /package/components/{DateTimePicker.js → DateTimePicker.tsx} +0 -0
- /package/components/{Icon.js → Icon.tsx} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useEffect} from 'react';
|
|
2
2
|
|
|
3
3
|
import apiClient from "../api/client";
|
|
4
|
-
import authStorage from "../
|
|
4
|
+
import authStorage from "../utilities/authStorage";
|
|
5
5
|
import settings from "../../../../config/settings";
|
|
6
6
|
import useAuth from '../hooks/useAuth';
|
|
7
7
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useState} from 'react';
|
|
2
2
|
import {Image as RNImage, StyleSheet, View} from "react-native";
|
|
3
3
|
|
|
4
|
-
import storage from '../auth/storage';
|
|
5
|
-
import * as Notifications from "expo-notifications";
|
|
6
4
|
import useAuth from "../hooks/useAuth";
|
|
7
|
-
import authStorage from "../auth/storage";
|
|
8
5
|
import settings from '../../../../config/api';
|
|
9
|
-
import AuthContext from "../auth/context";
|
|
10
6
|
|
|
11
7
|
function Image({style, uri, onPress, handleError, source}) {
|
|
12
|
-
const {user
|
|
8
|
+
const {user} = useAuth();
|
|
13
9
|
|
|
14
10
|
const tryAgain = async error => {
|
|
15
11
|
if (handleError !== null) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Device from "expo-device";
|
|
2
|
+
import * as Notifications from "expo-notifications";
|
|
3
|
+
import expoPushTokensApi from "../api/expoPushTokens";
|
|
4
|
+
import {useEffect} from "react";
|
|
5
|
+
import router from "../navigation/rootNavigation";
|
|
6
|
+
|
|
7
|
+
export default useNotifications = (notificationReceivedListener = notification => {}) => {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
registerForPushNotifications();
|
|
10
|
+
Notifications.addNotificationReceivedListener(notification => {
|
|
11
|
+
notificationReceivedListener(notification);
|
|
12
|
+
});
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
const registerForPushNotifications = () => registerForPushNotificationsAsync();
|
|
16
|
+
|
|
17
|
+
const registerForPushNotificationsAsync = async () => {
|
|
18
|
+
if (Device.isDevice) {
|
|
19
|
+
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
|
20
|
+
let finalStatus = existingStatus;
|
|
21
|
+
|
|
22
|
+
if (existingStatus !== 'granted') {
|
|
23
|
+
const { status } = await Notifications.requestPermissionsAsync();
|
|
24
|
+
finalStatus = status;
|
|
25
|
+
}
|
|
26
|
+
if (finalStatus !== 'granted') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const token = (await Notifications.getExpoPushTokenAsync()).data;
|
|
30
|
+
expoPushTokensApi.register(token);
|
|
31
|
+
} else {
|
|
32
|
+
alert('Must use physical device for Push Notifications');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Platform.OS === 'android') {
|
|
36
|
+
Notifications.setNotificationChannelAsync('default', {
|
|
37
|
+
name: 'default',
|
|
38
|
+
importance: Notifications.AndroidImportance.MAX,
|
|
39
|
+
vibrationPattern: [0, 250, 250, 250],
|
|
40
|
+
lightColor: '#FF231F7C',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boneframework/native-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Expo Components for Bone Framework",
|
|
5
5
|
"main": "src/Bone.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,10 @@
|
|
|
35
35
|
"apisauce": "^3.0.1",
|
|
36
36
|
"expo-auth-session": "^5.5.2",
|
|
37
37
|
"expo-camera": "^15.0.13",
|
|
38
|
+
"expo-device": "^6.0.2",
|
|
39
|
+
"expo-image": "^1.12.13",
|
|
38
40
|
"expo-image-picker": "^15.0.7",
|
|
41
|
+
"expo-notifications": "^0.28.11",
|
|
39
42
|
"expo-secure-store": "^13.0.2",
|
|
40
43
|
"formik": "^2.4.6",
|
|
41
44
|
"jwt-decode": "^4.0.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|