EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

error when running app on iOS "**ReferenceError: Can't find variable: FIRInAppMessaging**" #1374

Open tiesco238 opened 4 years ago

tiesco238 commented 4 years ago

Hi,

I am trying to create an iOS app using Nativescript (vue flavour) to get the push notifications to work (nativescript-plugin-firebase) but i am keep getting errors when running tns..

CONSOLE ERROR file:///node_modules/nativescript-vue/dist/index.js:2129:21 [Vue warn]: Error in created hook: "ReferenceError: Can't find variable: FIRInAppMessaging"

This is the snippet of the console log:

tns run ios

Retrieving resting unlock: 0
CONSOLE LOG 'Firebase initialized'
6.6.0 - <AppMeasurement>[I-ACS023147] Google Analytics for Firebase has not been created. Please, configure Firebase by calling [FIRApp configure]
6.6.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
6.6.0 - [GoogleUtilities/AppDelegateSwizzler][I-SWZ001014] App Delegate does not conform to UIApplicationDelegate protocol.
6.6.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60100000 started
6.6.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
[Crashlytics:Crash:Reports] Packaged report with id '1aaeff627a3044ccbfb95837b7a41f50' for submission
You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
nw_endpoint_flow_protocol_connected [C1.1 IPv4#293b411c:443 in_progress channel-flow (satisfied)] Transport protocol connected
nw_protocol_tcp_log_summary [C1.2:3]
[<private> <private>:49784<-><private>:443]
Init: 1, Conn_Time: 0.000ms, Syn's: 1, WR_T: 0/0, RD_T: 0/0, TFO: 0/0/0, ECN: 0/1/0, TS: 0
RTT_Cache: none, rtt_upd: 0, rtt: 0.000ms, rtt_var: 250.000ms rtt_nc: 0.000ms, rtt_var_nc: 250.000ms
nw_endpoint_flow_protocol_disconnected [C1.2 IPv4#d86e8841:443 cancelled channel-flow (null)] Output protocol disconnected
TIC TLS Event [1:0x2825b0240]: 1, Pending(0)
Task <2225D69A-64EB-4E67-B96E-2C7860A59873>.<1> resuming, QOS(0x19)
CONSOLE LOG file:///node_modules/nativescript-vue/dist/index.js:10141:5 '{NSVue (Vue: 2.6.10 | NSVue: 2.4.0)} -> CreateElement(NativeFrame)'
TIC TCP Conn Start [2:0x2825bc0c0]
[C2 127.0.0.1:8098 tcp, url hash: 90a08456] start
nw_connection_report_state_with_handler_locked [C2] reporting state preparing
Task <2225D69A-64EB-4E67-B96E-2C7860A59873>.<1> setting up Connection 2
nw_socket_handle_socket_event [C2:2] Socket received CONNRESET event
nw_socket_handle_socket_event [C2:2] Socket received DISCONNECTED event
nw_socket_handle_socket_event [C2:2] Socket SO_ERROR [61: Connection refused]
nw_endpoint_flow_protocol_disconnected [C2 127.0.0.1:8098 in_progress socket-flow (satisfied)] Output protocol disconnected
nw_connection_report_state_with_handler_locked [C2] reporting state failed error Connection refused
TIC TCP Conn Event [2:0x2825bc0c0]: 3
TIC TCP Conn Failed [2:0x2825bc0c0]: 1:61 Err(61)
TIC TCP Conn Cancel [2:0x2825bc0c0]
[C2 127.0.0.1:8098 tcp, url hash: 90a08456] cancel
[C2 127.0.0.1:8098 tcp, url hash: 90a08456] cancelled
0.000s [C2 <private> 127.0.0.1:52379<->127.0.0.1:8098 socket-flow] path:start
0.000s [C2 <private> 127.0.0.1:52379<->127.0.0.1:8098 socket-flow] path:satisfied
0.000s [C2 <private> 127.0.0.1:52379<->127.0.0.1:8098 socket-flow] flow:start_connect
0.001s [C2 <private> 127.0.0.1:52379<->127.0.0.1:8098 socket-flow] flow:failed_connect Connection refused
0.001s [C2] path:cancel
nw_connection_report_state_with_handler_locked [C2] reporting state cancelled error Connection refused
TIC TCP Conn Destroyed [2:0x2825bc0c0]
Task <2225D69A-64EB-4E67-B96E-2C7860A59873>.<1> HTTP load failed (error code: -1004 [1:61])
Task <2225D69A-64EB-4E67-B96E-2C7860A59873>.<1> finished with error - code: -1004
CONSOLE ERROR file:///node_modules/nativescript-vue/dist/index.js:2129:21 [Vue warn]: Error in created hook: "ReferenceError: Can't find variable: FIRInAppMessaging"
found in
---> <App> at components/App.vue
<Frame>
<Root>

This is the code i used in vue (copied from git's demo vue project):

<script>

    const firebase = require("nativescript-plugin-firebase");
    import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
...

And further down:

data() {
      return {

      }
    },
      created() {
          // wire up an 'onMessageClicked' callback
          inappmessaging.onMessageClicked(message => {
              console.log(">> inappmessaging onMessageClicked, campaign: " + message.campaignName + ", with url: " + message.actionURL);
              this.message = `Campaign ${message.campaignName} clicked`;
          });
          // 👉 .. and for fun, wire an 'onMessageImpression' callback so when know when the message is shown
          inappmessaging.onMessageImpression(message => {
              console.log(">> inappmessaging onMessageImpression, campaign: " + message.campaignName);
              this.message = `Campaign ${message.campaignName} seen`;
          });
      },

I did refresh my npm modules, install native-script-plugin-firebase and everything is working in xcode/profiles/push notifications..

Does somebody know what is wrong here. Is it a bug?

Thank you very much in advance,

Thijs

EddyVerbruggen commented 4 years ago

Which command do you use to run the app?

tiesco238 commented 4 years ago

tns run ios

EddyVerbruggen commented 4 years ago

OK. Do you have a repo I can look at?

tiesco238 commented 4 years ago

Sure, created a repo here: https://github.com/tiesco238/nativescript-push-notifications/tree/test

Sauvetonbio commented 4 years ago

Same issue here ! Thank you

EddyVerbruggen commented 4 years ago

@Sauvetonbio please share a repo and steps to reproduce.

@tiesco238 I just cloned your repo, ran npm i, then tns run ios and deployed the app without trouble to the simulator. Does it matter if it's a simulator or device?

tiesco238 commented 4 years ago

Well not sure, but i tested on a device. Coul you check please?

EddyVerbruggen commented 4 years ago

Could you check on a simulator first please?

tiesco238 commented 4 years ago

Please pull the git for latest version. inappmessaging.onMessageClicked causing the error. The app does not load.

tiesco238 commented 4 years ago

getting the same error on a simulator (tns run --emulator)

tiesco238 commented 4 years ago

@EddyVerbruggen do you get the error after pulling the repo?

Sauvetonbio commented 4 years ago

In my case, I need to delete the "platforms" folder before each build to be good. Else the app crash on iPhone device when starting with similars errors like "ReferenceError: Can't find variable: FIRInAppMessaging"