TypeError: undefined is not an object (evaluating i.subscribeTo()') plugin.js: 9
donau-software opened this issue · comments
Describe the bug
When calling fcm.subscribeTo(..) the mentioned exception is thrown, only on iOS, on Android works as expected
To Reproduce
import { FCM } from "@capacitor-community/fcm";
var fcm;
try {
fcm = new FCM();
} catch (e) {
console.error(e);
}
try {
PushNotifications.requestPermission().then(async (result) => {
if (result.granted) {
console.log("registering push notifications");
await PushNotifications.register();
}
});
} catch (e) {
console.error(e);
}
try {
await fcm.subscribeTo({ topic: "all" }); <--- here it crashes
if (user) {
await fcm.unsubscribeFrom({ topic: "not_logged" });
await fcm.subscribeTo({ topic: "logged" });
await fcm.subscribeTo({ topic: user.uid });
} else {
await fcm.subscribeTo({ topic: "not_logged" });
await fcm.unsubscribeFrom({ topic: "logged" });
}
} catch (e) {
console.log(fcm);
console.error(e);
}
From what i can see inot the source code, FCMPlugin is undefined
"@capacitor-community/fcm": "^1.1.2",
"@capacitor/core": "^2.4.7",
"@capacitor/ios": "^2.4.7",
Expected behavior
fcm.subscribeTo({topic: "all" }) should work and subscribe user to the "all" topic
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS 11.5.2
- Browser safari
- Version 14.1.2
Smartphone (please complete the following information):
- Device: Iphone 7 Plus
- OS: iOS 14.7.1
- Browser safari
- Version ?
Additional context
Add any other context about the problem here.