capacitor-community / capacitor-community/fcm

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

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
272
Forks
96
PR merge metrics
No merged PRs in 30d

Description

**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.

Contributor guide

Open the contributing guide

Research direction

Start at plugin.js:9 and trace the FCMPlugin entry point used by fcm.subscribeTo() on iOS. Reproduce with @capacitor-community/fcm 1.1.2 and Capacitor 2.4.7 on the stated iOS environment; done means subscribing to the all topic succeeds without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, ios, typescript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.