@boneframework/native-components 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.
|
@@ -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
|
|
|
@@ -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.18",
|
|
4
4
|
"description": "Expo Components for Bone Framework",
|
|
5
5
|
"main": "src/Bone.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -31,10 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@react-native-async-storage/async-storage": "^1.24.0",
|
|
33
33
|
"@react-native-community/datetimepicker": "^8.2.0",
|
|
34
|
+
"@react-native-community/netinfo": "^11.3.2",
|
|
34
35
|
"apisauce": "^3.0.1",
|
|
35
36
|
"expo-auth-session": "^5.5.2",
|
|
36
37
|
"expo-camera": "^15.0.13",
|
|
38
|
+
"expo-device": "^6.0.2",
|
|
37
39
|
"expo-image-picker": "^15.0.7",
|
|
40
|
+
"expo-notifications": "^0.28.11",
|
|
38
41
|
"expo-secure-store": "^13.0.2",
|
|
39
42
|
"formik": "^2.4.6",
|
|
40
43
|
"jwt-decode": "^4.0.0",
|