Skip to content

Commit

Permalink
set firebase token to localstorage
Browse files Browse the repository at this point in the history
Signed-off-by: Nitesh Balusu <84944042+niteshbalusu11@users.noreply.github.com>
  • Loading branch information
niteshbalusu11 committed Dec 1, 2023
1 parent f9facbe commit cd79679
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/state/NotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getFcmToken, localNotification, notificationListener } from "../utils/p
import { toast } from "../utils";

import logger from "./../utils/log";
import { StorageItem, getItem, getItemObject, setItem } from "../storage/app";
const log = logger("NotificationManager");

interface ILocalNotificationPayload {
Expand Down Expand Up @@ -44,7 +45,10 @@ export const notificationManager: INotificationManagerModel = {
return;
}

await getFcmToken();
const token = await getFcmToken();
if (!!token) {
await setItem(StorageItem.firebaseToken, token);
}
notificationListener();
} else if (PLATFORM === "android") {
const granted = await PermissionsAndroid.request(
Expand All @@ -53,7 +57,10 @@ export const notificationManager: INotificationManagerModel = {
if (granted === "denied" || granted === "never_ask_again") {
log.w("Post notification permission was denied", [granted]);
} else {
await getFcmToken();
const token = await getFcmToken();
if (!!token) {
await setItem(StorageItem.firebaseToken, token);
}
notificationListener();
return;
}
Expand Down

0 comments on commit cd79679

Please sign in to comment.