andrehtissot / cordova-plugin-fcm-with-dependecy-updated

Google FCM Push Notifications Cordova Plugin
MIT License
210 stars 279 forks source link

FCM.onNotification() stop working in iOS error: The default Firebase app has not yet been configured. Add `[FIRApp configure];` #99

Closed feliperivero99 closed 4 years ago

feliperivero99 commented 4 years ago

I am working with IONIC 4 developing an app.

I was receiving messages via firebase fine, the functionality was working perfect in IOS, until the following error started to appear.

I was receiving messages normally. I made some changes, in the code, I recompiled in IOS. I dont find solution:


6.24.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
2020-06-11 15:54:48.685701-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-06-11 15:54:48.686034-0400 PinFamily[1665:1441506] 

These are my plugins.

image

This is my code, inside app.component.ts:

window['FCMPlugin'].requestPushPermissionIOS((response) => {
    console.log('permission given', response);
}, (response) => {
    console.log('permission rejected', response);
});

this.fcm.onTokenRefresh().subscribe(token => {
    console.log(token);
});

this.fcm.getToken().then(token => {
    console.log("Inicializacion: " + token);
});

this.fcm.onNotification().subscribe(data => {
    console.log("------------llega la data");
    console.log("------------llega la data");
    this.idmensaje = data["gcm.notification.id"];
    console.log(this.idmensaje);
    this.accionmensaje = data["gcm.notification.action"];
    console.log(this.idmensaje);
    let objmesaje = JSON.parse(data["alert"]);
    this.tituloError = objmesaje.title;
    this.mensajeError = objmesaje.message;
    this.botonError = objmesaje.btn_text;
    console.log("----------inserto en tabla");
    this.insertRow("notificaciones", this.mensajeError, this.idmensaje, this.accionmensaje);

    if (data.wasTapped) {
        console.log('---------------------Received in background');
        //this.presentAlertConfirm();
    } else {
        console.log('-----------------Received in foreground');
        //this.presentAlertConfirm();
    }
});

These are the logs:

[14:52, 11/6/2020] +56 9 5713 8540: eBoHzO_yb0yyq4gBIjSnzb:APA91bEEBMgDKHBtcIY50po8ZoC-GkQFvH6gF8k93l2z5ZVCEFf2Iw2Q2XLMXqOAVSMiEujSeh6z9Ps7Orm88LY75Da8PKcg0I9IlMRnVeR0lNk4jB5476yUT3dg1jYCy8uw5odGcGDq
[14:56, 11/6/2020] +56 9 5713 8540: 2020-06-11 15:54:48.061395-0400 PinFamily[1665:1441317] <Warning>: The value for FacebookAdvertiserIDCollectionEnabled is currently set to FALSE so you're sending app events without collecting Advertiser ID. This can affect the quality of your advertising and analytics results.
2020-06-11 15:54:48.141805-0400 PinFamily[1665:1441317] Apache Cordova native platform version 5.1.1 is starting.
2020-06-11 15:54:48.141908-0400 PinFamily[1665:1441317] Multi-tasking -> Device: YES, App: YES
2020-06-11 15:54:48.159323-0400 PinFamily[1665:1441317] CDVWKWebViewEngine: trying to inject XHR polyfill
2020-06-11 15:54:48.184695-0400 PinFamily[1665:1441317] WF: === Starting WebFilter logging for process PinFamily
2020-06-11 15:54:48.184740-0400 PinFamily[1665:1441317] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2020-06-11 15:54:48.184777-0400 PinFamily[1665:1441317] WF: _WebFilterIsActive returning: NO
2020-06-11 15:54:48.194465-0400 PinFamily[1665:1441317] CDVWKWebViewEngine will reload WKWebView if required on resume
2020-06-11 15:54:48.194573-0400 PinFamily[1665:1441317] Using Ionic WKWebView
2020-06-11 15:54:48.194823-0400 PinFamily[1665:1441317] [CDVTimer][console] 0.044942ms
2020-06-11 15:54:48.194941-0400 PinFamily[1665:1441317] [CDVTimer][handleopenurl] 0.054002ms
2020-06-11 15:54:48.196273-0400 PinFamily[1665:1441317] [CDVTimer][intentandnavigationfilter] 1.294971ms
2020-06-11 15:54:48.196441-0400 PinFamily[1665:1441317] [CDVTimer][gesturehandler] 0.059962ms
2020-06-11 15:54:48.197371-0400 PinFamily[1665:1441317] [CDVTimer][base64togallery] 0.053048ms
2020-06-11 15:54:48.198742-0400 PinFamily[1665:1441317] [CDVTimer][file] 1.230955ms
2020-06-11 15:54:48.198939-0400 PinFamily[1665:1441317] Starting Facebook Connect plugin
2020-06-11 15:54:48.199059-0400 PinFamily[1665:1441317] [CDVTimer][facebookconnectplugin] 0.209928ms
2020-06-11 15:54:48.199219-0400 PinFamily[1665:1441317] GooglePlus pluginInitizalize
2020-06-11 15:54:48.199313-0400 PinFamily[1665:1441317] [CDVTimer][googleplus] 0.144005ms
2020-06-11 15:54:48.199426-0400 PinFamily[1665:1441317] [CDVTimer][inappbrowser] 0.033975ms
2020-06-11 15:54:48.200629-0400 PinFamily[1665:1441317] CDVPlugin class CDVUIInAppBrowser (pluginName: uiinappbrowser) does not exist.
2020-06-11 15:54:48.200768-0400 PinFamily[1665:1441317] [CDVTimer][uiinappbrowser] 1.258969ms
2020-06-11 15:54:48.200955-0400 PinFamily[1665:1441317] [CDVTimer][wkinappbrowser] 0.094056ms
2020-06-11 15:54:48.201500-0400 PinFamily[1665:1441317] CDVIonicKeyboard: no resize
2020-06-11 15:54:48.202256-0400 PinFamily[1665:1441317] [CDVTimer][cdvionickeyboard] 0.931025ms
2020-06-11 15:54:48.204248-0400 PinFamily[1665:1441317] [CDVTimer][splashscreen] 1.912951ms
2020-06-11 15:54:48.205873-0400 PinFamily[1665:1441317] [CDVTimer][statusbar] 1.501083ms
2020-06-11 15:54:48.205970-0400 PinFamily[1665:1441317] [CDVTimer][uniquedeviceid] 0.036001ms
2020-06-11 15:54:48.206087-0400 PinFamily[1665:1441317] [CDVTimer][socialsharing] 0.084996ms
2020-06-11 15:54:48.206122-0400 PinFamily[1665:1441317] [CDVTimer][TotalPluginStartup] 11.386991ms
2020-06-11 15:54:48.215751-0400 PinFamily[1665:1441317] DidFinishLaunchingWithOptions
2020-06-11 15:54:48.268403-0400 PinFamily[1665:1441317] app become active
2020-06-11 15:54:48.270581-0400 PinFamily[1665:1441317] FB Hybrid app events are not enabled
2020-06-11 15:54:48.357122-0400 PinFamily[1665:1441317] IAB.close() called but it was already closed.
2020-06-11 15:54:48.599337-0400 PinFamily[1665:1441317] Device FCM Token: [redacted]
2020-06-11 15:54:48.627755-0400 PinFamily[1665:1441506] [] tcp_input [C1.1:3] flags=[R] seq=3896249536, ack=0, win=0 state=CLOSED rcv_nxt=3896249536, snd_una=3211020898
2020-06-11 15:54:48.642150-0400 PinFamily[1665:1441532] [] tcp_input [C1.1:3] flags=[R] seq=3896249536, ack=0, win=0 state=CLOSED rcv_nxt=3896249536, snd_una=3211020898
2020-06-11 15:54:48.653086-0400 PinFamily[1665:1441529] 6.24.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
2020-06-11 15:54:48.685701-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-06-11 15:54:48.686034-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-06-11 15:54:48.686183-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60500000 started
2020-06-11 15:54:48.686372-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2020-06-11 15:54:48.690696-0400 PinFamily[1665:1441501] 6.24.0 - [Firebase/Analytics][I-ACS025036] App Delegate Proxy is disabled
2020-06-11 15:54:48.700822-0400 PinFamily[1665:1441532] 6.24.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-06-11 15:54:48.718418-0400 PinFamily[1665:1441506] 6.24.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-06-11 15:54:48.854597-0400 PinFamily[1665:1441532] [] tcp_input [C4.1:3] flags=[R] seq=4188077820, ack=0, win=0 state=CLOSED rcv_nxt=4188077820, snd_una=559241019
2020-06-11 15:54:48.856929-0400 PinFamily[1665:1441532] [] tcp_input [C4.1:3] flags=[R] seq=4188077820, ack=0, win=0 state=CLOSED rcv_nxt=4188077820, snd_una=559241019
2020-06-11 15:54:50.933117-0400 PinFamily[1665:1441317] ERROR Internal navigation rejected - <allow-navigation> not set for url='gap://ready'
2020-06-11 15:54:50.976021-0400 PinFamily[1665:1441317] ERROR: Plugin 'AndroidFullScreen' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2020-06-11 15:54:50.976209-0400 PinFamily[1665:1441317] FAILED pluginJSON = ["INVALID","AndroidFullScreen","immersiveMode",[]]
2020-06-11 15:54:50.977890-0400 PinFamily[1665:1441317] FCMPlugin.js: is created
2020-06-11 15:54:50.979170-0400 PinFamily[1665:1441317] Ionic Native: deviceready event fired after 2246 ms
2020-06-11 15:54:50.987490-0400 PinFamily[1665:1441317] requestPushPermission
2020-06-11 15:54:50.995500-0400 PinFamily[1665:1441317] get Token
2020-06-11 15:54:50.995634-0400 PinFamily[1665:1441317] view registered for notifications
2020-06-11 15:54:50.995810-0400 PinFamily[1665:1441317] OPEN database: pinfamily.db
2020-06-11 15:54:50.996136-0400 PinFamily[1665:1441317] -[SQLitePlugin pluginInitialize] [Line 38] Initializing SQLitePlugin
2020-06-11 15:54:50.996537-0400 PinFamily[1665:1441317] -[SQLitePlugin pluginInitialize] [Line 45] Detected docs path: /var/mobile/Containers/Data/Application/5719B47A-23FC-4E0D-A99A-A8E62A27CFB0/Documents
2020-06-11 15:54:50.996667-0400 PinFamily[1665:1441317] -[SQLitePlugin pluginInitialize] [Line 49] Detected Library path: /var/mobile/Containers/Data/Application/5719B47A-23FC-4E0D-A99A-A8E62A27CFB0/Library
2020-06-11 15:54:50.996939-0400 PinFamily[1665:1441317] -[SQLitePlugin pluginInitialize] [Line 65] no cloud sync directory already exists at path: /var/mobile/Containers/Data/Application/5719B47A-23FC-4E0D-A99A-A8E62A27CFB0/Library/LocalDatabase
2020-06-11 15:54:50.997411-0400 PinFamily[1665:1441317] -[SQLitePlugin pluginInitialize] [Line 93] no cloud sync at path: /var/mobile/Containers/Data/Application/5719B47A-23FC-4E0D-A99A-A8E62A27CFB0/Library/LocalDatabase
2020-06-11 15:54:50.997716-0400 PinFamily[1665:1441506] -[SQLitePlugin closeNow:] [Line 233] close: db name was not open: pinfamily.db
2020-06-11 15:54:51.013949-0400 PinFamily[1665:1441317] database already open: pinfamily.db
2020-06-11 15:54:51.014168-0400 PinFamily[1665:1441317] Cordova view ready
2020-06-11 15:54:51.014477-0400 PinFamily[1665:1441317] new transaction is queued, waiting for open operation to finish
2020-06-11 15:54:51.016623-0400 PinFamily[1665:1441317] Inicializacion: eBoHzO_yb0yyq4gBIjSnzb:APA91bEEBMgDKHBtcIY50po8ZoC-GkQFvH6gF8k93l2z5ZVCEFf2Iw2Q2XLMXqOAVSMiEujSeh6z9Ps7Orm88LY75Da8PKcg0I9IlMRnVeR0lNk4jB5476yUT3dg1jYCy8uw5odGcGDq
2020-06-11 15:54:51.021336-0400 PinFamily[1665:1441506] -[SQLitePlugin openNow:] [Line 176] open full db path: /var/mobile/Containers/Data/Application/5719B47A-23FC-4E0D-A99A-A8E62A27CFB0/Library/LocalDatabase/pinfamily.db
2020-06-11 15:54:51.023297-0400 PinFamily[1665:1441317] ERROR: {"code":2,"source":"Native","exception":null}
2020-06-11 15:54:51.026465-0400 PinFamily[1665:1441317] unknown
2020-06-11 15:54:51.027182-0400 PinFamily[1665:1441317] FCMPlugin Ready OK
2020-06-11 15:54:51.038095-0400 PinFamily[1665:1441317] OPEN database: pinfamily.db - OK
2020-06-11 15:54:51.049779-0400 PinFamily[1665:1441317] Table Created! notificaciones
2020-06-11 15:54:51.103865-0400 PinFamily[1665:1441317] database already open: pinfamily.db
2020-06-11 15:54:51.168915-0400 PinFamily[1665:1441317] ERROR: {"code":2,"source":"Native","exception":null}
2020-06-11 15:54:51.210293-0400 PinFamily[1665:1441317] database already open: pinfamily.db
andrehtissot commented 4 years ago

The warning bellow is expected, as the plugin's initialization is delayed on purpose to avoid deadlock issues with Watchdog.

The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.

Did you wrap the calls to this.fcm or window['FCMPlugin'] on a platform.ready().then(() => { //* ... *// })?

I also recommend to, on facing an error, to try to upgrade to last version, or at least later minor version, as there are many small fixes for corner cases that you might also face.

If after upgrading to v6.4.3, or v7.0.0-beta.2 (for a better ionic support), you still see the same issues, please share a hello world application and list the interactions that you performed that led to the bug.

feliperivero99 commented 4 years ago

Hello, I will downloaded the new plugin version.

Did you wrap the calls to this.fcm or window['FCMPlugin'] on a platform.ready().then(() => { // ... // })?

Yes I did. All my calls to the FCM plugin, are inside platform.ready().then(() =>.

On the other hand, I have been testing the application. I have noticed the following. Sometimes works and another times dont work.

Looking into the logs I noticed the APNS token sometimes is generated and sometines it doesnt.

Initializing the application I see this in the logs

2020-06-12 17:52:14.127396-0400 PinFamily[1931:1674476] Device FCM Token: [redacted] 2020-06-12 17:52:14.127396-0400 PinFamily[1931:1674476] Device APNS Token: [redacted]

In this case I got the firebase notifications, perfectly. But when I compiled and install again, the FCM token is created but not the APNS token.

Only this line appears: 2020-06-12 17:52:14.127396-0400 PinFamily[1931:1674476] Device FCM Token: [redacted]

And I dont received any firebase notifications.

I have to compile and reinstall the app, several times until the APNS token is created again, and I can received again firebase notification.

I added this:


window['FCMPlugin'].getAPNSToken(
  function(token) {
    console.info("Retrieved token APNS: "+token)
  },
  function(error) {
    console.error(error);
  }
);

But it doesn't seem to work.

Any ideas??

andrehtissot commented 4 years ago

Please share a hello world application that I can use to debug.

andrehtissot commented 4 years ago

Issue closed due to inactivity.