Some cleaning on notifs
This commit is contained in:
37
App.js
37
App.js
@@ -32,14 +32,27 @@ const theme = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Notifications.setNotificationHandler({
|
Notifications.setNotificationHandler({
|
||||||
handleNotification: async () => ({
|
handleNotification: async () => {
|
||||||
shouldShowAlert: true,
|
//console.log("notif background");
|
||||||
shouldPlaySound: false,
|
return {
|
||||||
shouldSetBadge: false,
|
shouldShowAlert: true,
|
||||||
}),
|
shouldPlaySound: true,
|
||||||
|
shouldSetBadge: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function registerForPushNotificationsAsync() {
|
async function registerForPushNotificationsAsync() {
|
||||||
|
|
||||||
|
if (Platform.OS === 'android') {
|
||||||
|
Notifications.setNotificationChannelAsync('default', {
|
||||||
|
name: 'default',
|
||||||
|
importance: Notifications.AndroidImportance.MAX,
|
||||||
|
vibrationPattern: [0, 250, 250, 250],
|
||||||
|
lightColor: '#FF231F7C',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let token;
|
let token;
|
||||||
if (Device.isDevice) {
|
if (Device.isDevice) {
|
||||||
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
||||||
@@ -53,21 +66,9 @@ async function registerForPushNotificationsAsync() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
token = (await Notifications.getExpoPushTokenAsync({ projectId: "c2bb4d4e-4d4d-4f34-a873-7cad78c6023c", })).data;
|
token = (await Notifications.getExpoPushTokenAsync({ projectId: "c2bb4d4e-4d4d-4f34-a873-7cad78c6023c", })).data;
|
||||||
console.log(token);
|
|
||||||
} else {
|
} else {
|
||||||
alert('Must use physical device for Push Notifications');
|
alert('Must use physical device for Push Notifications');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform.OS === 'android') {
|
|
||||||
Notifications.setNotificationChannelAsync('default', {
|
|
||||||
name: 'default',
|
|
||||||
importance: Notifications.AndroidImportance.MAX,
|
|
||||||
vibrationPattern: [0, 250, 250, 250],
|
|
||||||
lightColor: '#FF231F7C',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(token);
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +90,13 @@ const MainNavigation = () => {
|
|||||||
|
|
||||||
// This listener is fired whenever a notification is received while the app is foregrounded
|
// This listener is fired whenever a notification is received while the app is foregrounded
|
||||||
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
|
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
|
||||||
|
//console.log("got notif", notification)
|
||||||
setNotification(notification);
|
setNotification(notification);
|
||||||
});
|
});
|
||||||
|
|
||||||
// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
|
// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
|
||||||
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
|
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
|
||||||
|
//console.log("got notif click", notification)
|
||||||
console.log(response);
|
console.log(response);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
30
package-lock.json
generated
30
package-lock.json
generated
@@ -20,6 +20,7 @@
|
|||||||
"expo-image-picker": "~14.0.2",
|
"expo-image-picker": "~14.0.2",
|
||||||
"expo-notifications": "~0.17.0",
|
"expo-notifications": "~0.17.0",
|
||||||
"expo-status-bar": "~1.4.2",
|
"expo-status-bar": "~1.4.2",
|
||||||
|
"expo-task-manager": "~11.0.1",
|
||||||
"expo-updates": "~0.15.6",
|
"expo-updates": "~0.15.6",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"react": "18.1.0",
|
"react": "18.1.0",
|
||||||
@@ -6879,6 +6880,17 @@
|
|||||||
"resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz",
|
||||||
"integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ=="
|
"integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/expo-task-manager": {
|
||||||
|
"version": "11.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/expo-task-manager/-/expo-task-manager-11.0.1.tgz",
|
||||||
|
"integrity": "sha512-9KXWkQyzldiTBz0+wRe7ypQQ0m02j838f8j0pDRrDbW2X5hBUJWzDGq7OItJ5F9vDjJ3oRZikOAhFGj+wxh3EA==",
|
||||||
|
"dependencies": {
|
||||||
|
"unimodules-app-loader": "~4.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"expo": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/expo-updates": {
|
"node_modules/expo-updates": {
|
||||||
"version": "0.15.6",
|
"version": "0.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz",
|
"resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz",
|
||||||
@@ -12709,6 +12721,11 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/unimodules-app-loader": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/unimodules-app-loader/-/unimodules-app-loader-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-YlV0rOM9pjdeTMEGR0rr/u+F7f1ygINUsTEiRIPvBewTk3Si/Sm8Ur5f92n+f0Sy1EIuOTGgyGaUdjJBfAd0YA=="
|
||||||
|
},
|
||||||
"node_modules/union-value": {
|
"node_modules/union-value": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
@@ -18406,6 +18423,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz",
|
||||||
"integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ=="
|
"integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ=="
|
||||||
},
|
},
|
||||||
|
"expo-task-manager": {
|
||||||
|
"version": "11.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/expo-task-manager/-/expo-task-manager-11.0.1.tgz",
|
||||||
|
"integrity": "sha512-9KXWkQyzldiTBz0+wRe7ypQQ0m02j838f8j0pDRrDbW2X5hBUJWzDGq7OItJ5F9vDjJ3oRZikOAhFGj+wxh3EA==",
|
||||||
|
"requires": {
|
||||||
|
"unimodules-app-loader": "~4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"expo-updates": {
|
"expo-updates": {
|
||||||
"version": "0.15.6",
|
"version": "0.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz",
|
"resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz",
|
||||||
@@ -22861,6 +22886,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz",
|
||||||
"integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w=="
|
"integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w=="
|
||||||
},
|
},
|
||||||
|
"unimodules-app-loader": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/unimodules-app-loader/-/unimodules-app-loader-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-YlV0rOM9pjdeTMEGR0rr/u+F7f1ygINUsTEiRIPvBewTk3Si/Sm8Ur5f92n+f0Sy1EIuOTGgyGaUdjJBfAd0YA=="
|
||||||
|
},
|
||||||
"union-value": {
|
"union-value": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
|
|||||||
Reference in New Issue
Block a user