Skip to content

Commit

Permalink
#147 Fix notifications for android
Browse files Browse the repository at this point in the history
  • Loading branch information
syi0808 committed May 18, 2022
1 parent 74ff29b commit 2be78c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,25 @@ export default function App() {
if (status === "granted") {
const token = (await Notifications.getExpoPushTokenAsync()).data;
postExpoToken(token);
localStorage.setItem("isSendedToken", true);
}
}, 500);
}, []);

useEffect(() => {
check();
appPermission();
(
async () => {
const isSendedToken = (await localStorage.getItem("isSendedToken")) ?? false;
const { status } = await Notifications.getPermissionsAsync();
if (status === "granted" && !isSendedToken) {
const token = (await Notifications.getExpoPushTokenAsync()).data;
postExpoToken(token);
localStorage.setItem("isSendedToken", true);
}
}
)();
}, []);

if (!fontsLoaded) {
Expand Down

0 comments on commit 2be78c9

Please sign in to comment.