diff --git a/.env.example b/.env.example index 82a761e..b2196f7 100644 --- a/.env.example +++ b/.env.example @@ -4,11 +4,5 @@ POSTGRES_HOST= POSTGRES_ADMIN_USER= POSTGRES_ADMIN_PASSWORD= -USE_PUSH_NOTIFICATIONS=true - -FIREBASE_PROJECT_ID= -FIREBASE_PRIVATE_KEY= -FIREBASE_CLIENT_EMAIL= -FIREBASE_NOTIFICATION_TITLE=You have message from your contacts -FIREBASE_NOTIFICATION_BODY=Please open your app to read the message +USE_PUSH_NOTIFICATIONS='true' NOTIFICATION_WEBHOOK_URL= \ No newline at end of file diff --git a/package.json b/package.json index 37929be..23296b8 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "@aries-framework/node": "0.4.2", "@hyperledger/aries-askar-nodejs": "^0.1.1", "express": "^4.18.1", - "firebase-admin": "^11.10.1", "prettier": "^2.8.4", "tslog": "^3.3.3", "tsyringe": "^4.7.0", diff --git a/src/constants.ts b/src/constants.ts index 65a0366..bdf4faa 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -24,14 +24,6 @@ export const LOG_LEVEL = LogLevel.debug export const IS_DEV = process.env.NODE_ENV === 'development' export const USE_PUSH_NOTIFICATIONS = process.env.USE_PUSH_NOTIFICATIONS === 'true' -export const FIREBASE_PROJECT_ID = process.env.FIREBASE_PROJECT_ID -export const FIREBASE_PRIVATE_KEY = process.env.FIREBASE_PRIVATE_KEY - ? process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n') - : undefined -export const FIREBASE_CLIENT_EMAIL = process.env.FIREBASE_CLIENT_EMAIL -export const FIREBASE_NOTIFICATION_TITLE = process.env.FIREBASE_NOTIFICATION_TITLE -export const FIREBASE_NOTIFICATION_BODY = process.env.FIREBASE_NOTIFICATION_BODY - -export const NOTIFICATION_WEBHOOK_URL = process.env.NOTIFICATION_WEBHOOK_URL +export const NOTIFICATION_WEBHOOK_URL = process.env.NOTIFICATION_WEBHOOK_URL || 'http://localhost:5000' diff --git a/src/push-notifications/fcm/services/PushNotificationsFcmService.ts b/src/push-notifications/fcm/services/PushNotificationsFcmService.ts index 0154538..80cd6df 100644 --- a/src/push-notifications/fcm/services/PushNotificationsFcmService.ts +++ b/src/push-notifications/fcm/services/PushNotificationsFcmService.ts @@ -111,10 +111,10 @@ export class PushNotificationsFcmService { connectionId, }) - // if (!pushNotificationFcmRecord?.deviceToken) { - // this.logger.info(`No device token found for connectionId so skip sending notification`) - // return - // } + if (!pushNotificationFcmRecord?.deviceToken) { + this.logger.info(`No device token found for connectionId so skip sending notification`) + return + } // Prepare a message to be sent to the device @@ -141,11 +141,6 @@ export class PushNotificationsFcmService { public async processNotification(message: NotificationMessage) { try { - if (!NOTIFICATION_WEBHOOK_URL) { - this.logger.error("Notification webhook URL not found"); - return - } - const body = { fcmToken: message.token || 'abc', messageType: message.messageType, @@ -159,19 +154,7 @@ export class PushNotificationsFcmService { body: JSON.stringify(body) }; - fetch(NOTIFICATION_WEBHOOK_URL, requestOptions) - .then(response => { - if (!response.ok) { - this.logger.error(`HTTP error! Status: ${response.status}`); - } - return response.json(); - }) - .then(data => { - this.logger.debug(`Data: ${data}`); - }) - .catch(error => { - this.logger.error(`Error: ${error}`); - }); + await fetch(NOTIFICATION_WEBHOOK_URL, requestOptions) } catch (error) { this.logger.error(`Error sending notification`, {