capacitor-community / fcm

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

iOS build error "extra argument 'toTopic' in call" #7

Closed thomas1511 closed 5 years ago

thomas1511 commented 5 years ago

When using capacitor-fcm in my project Xcode shows me the following error when building the application: "extra argument 'toTopic' in call";

this occurs in the following function: @objc func subscribeTo(_ call: CAPPluginCall) { let topicName = call.getString("topic") ?? "" Messaging.messaging().subscribe(toTopic: topicName) { error in // print("Subscribed to weather topic") if ((error) != nil) { print("ERROR while trying to subscribe topic \(topicName)") call.error("Can't subscribe to topic \(topicName)") }else{ call.success([ "message": "subscribed to topic \(topicName)" ]) } } }

(the same error is received at the unsubscribe call).

the last issue here is the getToken() function:

InstanceID.instanceID().instanceID { (result, error) in provides the error: 'Static member 'instanceID' cannot be used on instance of type 'InstanceID'"

stewones commented 5 years ago

what's capacitor version?

thomas1511 commented 5 years ago
"@capacitor/cli": "^1.0.0-beta.25",
"@capacitor/core": "^1.0.0-beta.25",
"@capacitor/ios": "^1.0.0-beta.25",
stewones commented 5 years ago

hum something may have broken, can you try on beta24?

thomas1511 commented 5 years ago

I just rolled back to beta.24. The errors remain: /node_modules/capacitor-fcm/ios/Plugin/Plugin/Plugin.swift:25:50: Extra argument 'toTopic' in call /node_modules/capacitor-fcm/ios/Plugin/Plugin/Plugin.swift:40:54: Extra argument 'fromTopic' in call /node_modules/capacitor-fcm/ios/Plugin/Plugin/Plugin.swift:52:20: Static member 'instanceID' cannot be used on instance of type 'InstanceID'

stewones commented 5 years ago

weirdo, I just deployed an app which uses that version. will double check this issue at weekend.

update: no luck, if anyone has a good way to reproduce this problem, I can try to help.

stewones commented 5 years ago

added a demo app

https://github.com/stewwan/capacitor-fcm-demo

urkh commented 5 years ago

I'm having the same issue. I'm using Capacitor v1.1.0

jmannau commented 5 years ago

In regards to the error Static member 'instanceID' cannot be used on instance of type 'InstanceID' For me, this was caused by out of date pod dependancies. I needed up run pod update to install the latest pods which fixed the error.

  1. cd ios/App
  2. pod update

I can then compile the app.

stewones commented 5 years ago

Yes. npx cap sync ios also does pod install. Remember to always run it after installing any plugin via npm install.