capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
237 stars 83 forks source link

Ionic integration compatible? #100

Closed jllaurado closed 1 year ago

jllaurado commented 2 years ago

Describe the bug I'm trying to use the module on ionic with capacitor and it give me an error. Following your instructions I've added an:

import { FCM } from '@capacitor-community/fcm';

in my fcm service but I'm not able to build, with the error:

Error: src/app/services/push.service.ts:12:21 - error TS2307: Cannot find module '@capacitor-community/fcm' or its corresponding type declarations.

12 import { FCM } from '@capacitor-community/fcm';


I've installed the module using:

$ npm i @capacitor-community/fcm

It seems trivial, but is it possible that it's imcompatible with ionic this module?

thanks.
ptmkenny commented 2 years ago

Did you cap sync as described in the README?

jllaurado commented 2 years ago

Thanks for the quick answer.

Yes, I've done it multiple times, and it detects the module also, but then you can see the error below. Here my steps:

$ ionic cap sync

ng.cmd run app:build .... Build at: 2021-10-21T11:21:17.088Z - Hash: 3b895d3e734b7c7916ac - Time: 13651ms capacitor.cmd sync [capacitor] √ Copying web assets from www to android\app\src\main\assets\public in 9.12s [capacitor] √ Creating capacitor.config.json in android\app\src\main\assets in 2.57ms [capacitor] √ copy android in 9.42s [capacitor] √ Updating Android plugins in 7.83ms [capacitor] [info] Found 6 Capacitor plugins for android: [capacitor] @capacitor-community/fcm@2.0.2 [capacitor] @capacitor/app@1.0.5 [capacitor] @capacitor/haptics@1.1.2 [capacitor] @capacitor/keyboard@1.1.2 [capacitor] @capacitor/push-notifications@1.0.6 [capacitor] @capacitor/status-bar@1.0.5 [capacitor] √ update android in 146.57ms [capacitor] √ copy web in 818.60μp [capacitor] √ update web in 793.80μp [capacitor] [info] Sync finished in 9.582s

jls@localhost:~/Development/bbs/test-fmc (master) $ ionic cap build --prod android

ng.cmd run app:build:production

  • Generating browser application bundles (phase: setup)... √ Browser application bundle generation complete. √ Browser application bundle generation complete.

./src/app/app.module.ts:6:0-47 - Error: Module not found: Error: Can't resolve '@capacitor-community/fcm' in 'C:\Users\jls\Development\test-fmc\src\app'

Error: src/app/app.module.ts:9:21 - error TS2307: Cannot find module '@capacitor-community/fcm' or its corresponding type declarations.

9 import { FCM } from '@capacitor-community/fcm';

jcesarmobile commented 1 year ago

I can't reproduce using latest ionic, capacitor and plugin, so it's probably fixed or related to some dependency in your project.

If you still face the issue, please, create a new one and provide a sample app where the issue can be reproduced.