costianur95 / nestjs-fcm

MIT License
20 stars 12 forks source link

How to find firebase.spec.json ? #7

Open UjjualUSspericorn opened 3 years ago

UjjualUSspericorn commented 3 years ago

I have gone through firebase console but couldn't find a firebase.spec.json file after creating a web app. While creating an android app in firebase it returns a google.json. Is this the one I should be using ?

costianur95 commented 3 years ago

Hello, The firebase.spec.json file can be found at Settings => Service accounts => Firebase Admin SDK and when you are on this page, just click "Generate new private key" after you configured application for iOS and Android.

UjjualUSspericorn commented 3 years ago

Thank you . It worked . it throwed error for missing json file in dist folder. The error was resolved copying to dist folder. Is it appropriate to copy file in the dist folder ? Also is it possible to use topics instad of device token

return await this.fcmService.sendNotification([ 'device_id_1', 'device_id_2', ], { data:{ } }, true );

costianur95 commented 3 years ago

Thank you . It worked . it throwed error for missing json file in dist folder. The error was resolved copying to dist folder. Is it appropriate to copy file in the dist folder ? => no it isn't proper solution. You should in general construct the path with nodejs path library and _dirname property, looking from dist folder and point to whatever folder you like to put your firebase config file. Dist folder is designed to be volatile based on your code base.

Also is it possible to use topics instad of device token => for the moment is not possible, but you are free to make a pull request with that feature :)

UjjualUSspericorn commented 3 years ago

Hi I gave path like given below. But it throwed error like no such directory or file found on path .. dist/config/fcm/firebase.spec.... That is why I copied the json to dist folder. any comments on this ? FcmModule.forRoot({ firebaseSpecsPath: path.resolve(__dirname, '../config/fcm/firebase.spec.json'), }),

hamzatrq commented 2 years ago

You are not supposed to copy it manually. Use the nest-cli.json config file for it. Update the nest-cli.json to copy config folder under dist on build.

  "compilerOptions": {
    "assets": [
      "config/**/*",
    ],

For more information read this: https://docs.nestjs.com/cli/monorepo#assets