Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: undefined is not an object (evaluating i.subscribeTo()') plugin.js: 9 #98

Open
donau-software opened this issue Oct 6, 2021 · 0 comments

Comments

@donau-software
Copy link

donau-software commented Oct 6, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant