capacitor-community / fcm

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

Fail to subscribe to topic #50

Closed golontico closed 4 years ago

golontico commented 4 years ago

I try to subscribe to an X token in Android and I can't make it happen and the catch doesn't give me any results

I have the latest version 1.0.8 installed, synchronize the project, recreate it, add part of my implementation.

PushNotifications.register() .then(() => { fcm .subscribeTo({ topic: topicName }) .then(r => console.log('Suscrito a topic', topicName)) .catch(err => console.log('Error', err)); }) .catch((err) => { console.log('Topic ' + topicName + '!'); console.log('Error catch subscribe to topic', JSON.stringify(err)); } );

the anwser of Android Studio "error catch" JSON.stringify(err) shown " typeerror cannot read property 'toSubscribe' of undefined "

I try with the example code(https://github.com/capacitor-community/fcm/blob/master/example/src/app/home/home.page.ts) a shows the same error

error

golontico commented 4 years ago

Sorry was my fault i did not add import com.getcapacitor.community.fcm.FCMPlugin; and then inside the init callback add(FCMPlugin.class); Now everythings works!

vigamage commented 2 years ago

hi @golontico Can you pls add a sample on how to do this initialization? In the documentation, I cannot see it is mentioned