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

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

TypeError: Object(...) is not a function #122

Closed andrehtissot closed 3 years ago

andrehtissot commented 4 years ago

@Stephane84 its getting on black white screen after run on device.

image

Originally posted by @piyushysoft in https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues/111#issuecomment-656728456

andrehtissot commented 4 years ago

I see no Object(...) function in current version 7.0.3.

Which version are you running, @piyushysoft?

Stephane84 commented 4 years ago

Is your import is : import {FCM} from "cordova-plugin-fcm-with-dependecy-updated/ionic/v4"; No node_module in this line, or /FCM at the end ?

piyushysoft commented 4 years ago

I see no Object(...) function in current version 7.0.3.

Which version are you running, @piyushysoft?

hello @andrehtissot yes I am using version is 7.0.3

piyushysoft commented 4 years ago

Is your import is : import {FCM} from "cordova-plugin-fcm-with-dependecy-updated/ionic/v4"; No not module in this line, or /FCM at the end ? hello @andrehtissot yes I am using same as per suggestion its given me token in ios. at the time app is background and closed its working good. when app is open or is in foreground this is not working in ios and android ,

piyushysoft commented 4 years ago

hello @andrehtissot
In android and ios when app is open that time notification is didn't came using this plugin. please guide me is there any thing i need to do.

mwillbanks commented 4 years ago

I am having this same issue....

import { FCM } from "cordova-plugin-fcm-with-dependecy-updated/ionic/v4";

TypeError: Object is not a function. (In 'Object(_ionic_native_core__WEBPACK_IMPORTED_MODULE_2__["Plugin"])', 'Object' is an instance of Object)
warnings — client:148

Basically ends up reflecting on this area:

FCM = __decorate(
    [
        Plugin({
            pluginName: 'FCM',
            plugin: 'cordova-plugin-fcm-with-dependecy-updated',
            pluginRef: 'FCM',
            repo: 'https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated',
            platforms: ['Android', 'iOS']
        }),
        Injectable()
    ],
    FCM
)
piyushysoft commented 4 years ago

@mwillbanks Please share your log like I share on first comment.

andrehtissot commented 4 years ago

Got the problem. It'll be addressed in the next few days.

mwillbanks commented 4 years ago

@andrehtissot how are we looking? if you provide any feedback of where you might think this is, i could take a look at solving this with a PR as well...

andrehtissot commented 4 years ago

@mwillbanks

As you can see in the the file ionic/v4/FCM.js, the entities imported there are Injectable and Plugin.

Injectable and Plugin, should for the user's version of angular/ionic, to result in a function.

Unfortunately, that is not the case due to its types being based on @angular/core and @ionic-native/core, version "^10.0.3" and "^5.27.0", respectively. src/ionic/v4/FCM.ts

piyushysoft commented 4 years ago

Is your import is : import {FCM} from "cordova-plugin-fcm-with-dependecy-updated/ionic/v4"; No not module in this line, or /FCM at the end ? hello @andrehtissot yes I am using same as per suggestion its given me token in ios. at the time app is background and closed its working good. when app is open or is in foreground this is not working in ios and android ,

@andrehtissot this is resolved or still its pending ? When app is in fore ground notification is not working only background and close state notification is working.

andrehtissot commented 4 years ago

@piyushysoft Still pending, sorry.

piyushysoft commented 4 years ago

@piyushysoft Still pending, sorry.

Ok thanks for replay. Once its done please inform me..

andrehtissot commented 4 years ago

@piyushysoft I wasn't able to reproduce this bug.

Would you provide your package.json or, better yet, a app example that I can clone and debug?

piyushysoft commented 4 years ago

@piyushysoft I wasn't able to reproduce this bug.

Would you provide your package.json or, better yet, a app example that I can clone and debug?

Hello @andrehtissot

please review my package.json below.

 "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@ionic-native/camera": "^5.26.0",
    "@ionic-native/core": "^5.0.7",
    "@ionic-native/crop": "^5.27.0",
    "@ionic-native/fcm": "^5.27.0",
    "@ionic-native/file": "^5.26.0",
    "@ionic-native/file-transfer": "^5.26.0",
    "@ionic-native/geolocation": "^5.26.0",
    "@ionic-native/location-accuracy": "^5.26.0",
    "@ionic-native/media-capture": "^5.26.0",
    "@ionic-native/native-geocoder": "^5.26.0",
    "@ionic-native/photo-viewer": "^5.26.0",
    "@ionic-native/social-sharing": "^5.26.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.2.0",
    "@ngx-translate/core": "^12.1.2",
    "@ngx-translate/http-loader": "^4.0.0",
    "a": "^2.1.2",
    "com-sarriaroman-photoviewer": "^1.2.4",
    "cordova-ios": "^5.1.1",
    "cordova-plugin-add-swift-support": "^2.0.2",
    "cordova-plugin-camera": "^4.1.0",
    "cordova-plugin-crop": "^0.4.0",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.0.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-media-capture": "^3.0.3",
    "cordova-plugin-nativegeocoder": "^3.4.1",
    "cordova-plugin-request-location-accuracy": "^2.3.0",
    "cordova-plugin-x-socialsharing": "^5.6.8",
    "es6-promise-plugin": "^4.2.2",
    "jquery": "^3.5.1",
    "message": "0.0.1",
    "ng2-signalr": "^8.0.2",
    "plugin": "0.3.3",
    "rxjs": "~6.5.1",
    "signalr": "^2.4.1",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.5",
    "@angular/cli": "~9.1.5",
    "@angular/compiler": "~9.1.6",
    "@angular/compiler-cli": "~9.1.6",
    "@angular/language-service": "~9.1.6",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.2.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  },
andrehtissot commented 4 years ago

@piyushysoft I've created a branch and replicated your dependencies. But got no issues.

https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated-ionic-v5-example/blob/issue122-piyushysoft-example/package.json

Would you try to clone this app and try it?

piyushysoft commented 4 years ago

@piyushysoft I've created a branch and replicated your dependencies. But got no issues.

https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated-ionic-v5-example/blob/issue122-piyushysoft-example/package.json

Would you try to clone this app and try it?

Hello @andretissot I already mention above notification is working. I have issue with only when app is open that time notification is not getting (IOS app). App close and in background it's working fine.. Thanks for checking now i try with clone app and get back to you..

Thanks

andrehtissot commented 4 years ago

Try the issue122-piyushysoft-example branch

piyushysoft commented 4 years ago

@andrehtissot I will try and let you know it's working or not..

Daxtek commented 4 years ago

Hello, I'm having the exact same issue after a run on device, black white screen, I cannot even get a token.

Screenshot 2020-09-07 at 10 09 49

I'm on Ionic 4 using the following import : import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/v4';

My package.json is as follow:

"dependencies": { "@angular/common": "~8.1.2", "@angular/compiler": "~8.1.2", "@angular/core": "~8.1.2", "@angular/forms": "~8.1.2", "@angular/platform-browser": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2", "@angular/router": "~8.1.2", "@ionic-native/app-rate": "^5.18.0", "@ionic-native/app-version": "^5.23.0", "@ionic-native/barcode-scanner": "^5.18.0", "@ionic-native/camera": "^5.18.0", "@ionic-native/camera-preview": "^5.18.0", "@ionic-native/core": "^5.18.0", "@ionic-native/email-composer": "^5.18.0", "@ionic-native/facebook": "^5.21.2", "@ionic-native/firebase-x": "^5.21.5", "@ionic-native/globalization": "^5.18.0", "@ionic-native/in-app-browser": "^5.18.0", "@ionic-native/in-app-purchase-2": "^5.20.0", "@ionic-native/native-storage": "^5.18.0", "@ionic-native/network": "^5.21.6", "@ionic-native/social-sharing": "^5.22.0", "@ionic-native/splash-screen": "^5.18.0", "@ionic-native/status-bar": "^5.18.0", "@ionic/angular": "^4.11.10", "@ionic/storage": "^2.2.0", "@ngx-translate/core": "^11.0.1", "@ngx-translate/http-loader": "^4.0.0", "@zxing/library": "^0.15.2", "cc.fovea.cordova.purchase": "^8.1.1", "cordova": "^9.0.0", "cordova-android": "^8.1.0", "cordova-ios": "^5.1.1", "cordova-plugin-add-swift-support": "^2.0.2", "cordova-plugin-androidx": "^1.0.2", "cordova-plugin-androidx-adapter": "^1.1.0", "cordova-plugin-app-preferences": "git+https://github.com/apla/me.apla.cordova.app-preferences.git", "cordova-plugin-app-version": "^0.1.9", "cordova-plugin-apprate": "^1.5.0", "cordova-plugin-camera": "^4.1.0", "cordova-plugin-camera-preview": "^0.11.1", "cordova-plugin-device": "~2.0.2", "cordova-plugin-dialogs": "^2.0.2", "cordova-plugin-email-composer": "^0.9.2", "cordova-plugin-fcm-with-dependecy-updated": "^7.3.1", "cordova-plugin-firebasex": "^8.0.0", "cordova-plugin-globalization": "^1.11.0", "cordova-plugin-inappbrowser": "^3.1.0", "cordova-plugin-ionic-keyboard": "^2.0.5", "cordova-plugin-ionic-webview": "^4.0.0", "cordova-plugin-nativestorage": "^2.3.2", "cordova-plugin-network-information": "^2.0.2", "cordova-plugin-splashscreen": "~5.0.2", "cordova-plugin-statusbar": "~2.4.2", "cordova-plugin-telerik-imagepicker": "^2.3.3", "cordova-plugin-whitelist": "~1.3.3", "cordova-plugin-x-socialsharing": "^5.6.4", "cordova-sqlite-storage": "^3.4.1", "core-js": "^2.6.11", "es6-promise-plugin": "^4.2.2", "parse": "^2.10.0", "phonegap-plugin-barcodescanner": "^8.1.0", "rxjs": "~6.5.1", "tslib": "^1.9.0", "uuid": "^8.0.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/architect": "~0.801.2", "@angular-devkit/build-angular": "^0.803.24", "@angular-devkit/core": "~8.1.2", "@angular-devkit/schematics": "~8.1.2", "@angular/cli": "8.1.3", "@angular/compiler": "~8.1.2", "@angular/compiler-cli": "~8.1.2", "@angular/language-service": "~8.1.2", "@ionic/angular-toolkit": "~2.0.0", "@ionic/lab": "^2.0.19", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "^5.2.0", "cordova-plugin-device": "^2.0.2", "cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-webview": "^4.1.3", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.4.3" },

PS: Sorry I don't know why the package.json code insert doesn't want to format

EDIT:

I switch to the ngx import : import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx'; And I can now get a token and receive push notification

andrehtissot commented 3 years ago

Hello, I'm having the exact same issue after a run on device, black white screen, I cannot even get a tok...

@Daxtek... So it did work for you after changing to ".../ionic/ngx", right?

Please create a new issue if not.

Daxtek commented 3 years ago

@andrehtissot Yes it did work me after changing to ".../ionic/ngx"