fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 991 forks source link

FCMPlugin is undefined in the app (but defined in the browser) #624

Closed freescout-helpdesk closed 4 years ago

freescout-helpdesk commented 4 years ago

Using Phonegap. By some reason FCMPlugin is always "undefined" in the emulator and in the built app (but defined in the browser):

document.addEventListener('deviceready', function() {
    console.log(typeof(FCMPlugin)); // result: [console.log] undefined
}, false);

config.xml:

    <engine name="android" spec="^7.1.4" />
    <plugin name="cordova-plugin-inappbrowser" spec="~3.1.0" />
    <plugin name="cordova-plugin-whitelist" spec="~1.3.4" />
    <plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="~4.1.0" />

Content-Security-Policy:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' * ws:;style-src 'self' 'unsafe-inline' data: blob:;media-src *;img-src 'self' data: content: *;script-src * 'unsafe-inline' 'unsafe-eval' data: blob:;">
freescout-helpdesk commented 4 years ago

Noticed, that in cordova-plugin-fcm-with-dependecy-updated is not mentioned in plugins/android.json (but mentioned in plugins/browser.json):

{
  "prepare_queue": {
    "installed": [],
    "uninstalled": []
  },
  "config_munge": {
    "files": {}
  },
  "installed_plugins": {
    "cordova-plugin-inappbrowser": {
      "PACKAGE_NAME": "net.freescout.app"
    },
    "cordova-plugin-whitelist": {
      "PACKAGE_NAME": "net.freescout.app"
    }
  },
  "dependent_plugins": {}
}

Adding it there manually does not help.

freescout-helpdesk commented 4 years ago

It does not work in the Phonegap emulator, but works in a built app!