Ionic 4 Beta: Object(...) is not a function

#1

Hi,

I just upgraded my app to beta 4 but I’m having some troubles when running ionic serve. The page stays blank and I get the following in my console.

index.js:197 Uncaught TypeError: Object(...) is not a function
    at index.js:197
    at Object../node_modules/@ionic-native/camera/index.js (index.js:257)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/app.module.ts (app.component.ts:10)
    at __webpack_require__ (bootstrap:81)
    at Object../src/main.ts (environment.ts:15)
    at __webpack_require__ (bootstrap:81)
    at Object.0 (app-configuration.ts:1)
    at __webpack_require__ (bootstrap:81)
    at checkDeferredModules (bootstrap:43)

It looks like something to do with the Camera plugin, but when I remove that dependency it will show an error on some other cordova plugin. I’ve added it to my providers like this.

import { Camera } from '@ionic-native/camera';

providers: [
        ...
        Camera,
        ...
    ]

Is there anything I am doing wrong? I know the camera won’t work in the browser, but now its not even starting the app in the browser, which it did with v3.

Appreciate any help!

Ionic Native Object(…) is not a function
Geolocation plugin with Ionic 4
#2

Did you change your version of Typescript when you were upgrading?

#3

I like to give the same answer over and over again…so

  1. Use ionic-native beta.14
  2. Correct your import by adding /ngx like import {Camera} from '@ionic-native/camera/ngx';

Next time plz before asking search thru the forum first https://forum.ionicframework.com/t/camera-in-ionic-v4 or https://forum.ionicframework.com/t/ionic-4-native-plugin-problem

1 Like
Ionic native (csZBar) problem whit Ionic v4
V4 and Native storage error?
Ionic 4 Barcode Scanner Plugin Compile Error
Ionic 4 Capacitor
#4

I did search and I will find them once they use proper thread titles and categories :slight_smile:

Thanks for your answer though!

#5

You’re welcome

In french we say something like “never two without three”, this was my third reply here about this subject, so I guess it’s fair :wink:

#6

Yeah I feel your pain and I can imagine it gets frustrating!

In the experience that I have on this forum, it became clear that this forum always was a bit of a mess. I mean users didn’t use proper titles, explanations, categories etc. But its been a while that I’ve used the forum extensively it might have changes since then!

I appreciate you taking the time and effort to answer the same question for the third time though! :wink:

#7

No worries, I did gave also the same answer on reddit :wink:

Generally speaking the forum works well I think, I mean I hang here since what … let me check …hahaha no way it seems that I hang on the forum since exactly 800 days in row today :joy: yep I think I like this forum

Have fun with v4

1 Like
#8
  1. Correct your import by adding /ngx like import {Camera} from '@ionic-native/camera/ngx';

if it doesn’t work also check your ionic/camera version is version 5. not 4.1x

1 Like
#9

Hi i am facing this issue with ‘@ionic-native/admob-free
When i added /ngx its not found.
plz help

#10

You probably mixed up some versions, what’s the content of your package.json?

#11

Its working now but I am only able to see banner ads but “Interstitial” and “Reward” is not working in test…

with real ads nothing is showing up :frowning: not even banner ads

following is my current code

showBanner() {

    let bannerConfig: AdMobFreeBannerConfig = {
        isTesting: true, // Remove in production
        autoShow: true//,
        //id: "ca-app-pub-3940256099942544/6300978111"
    };

    this.admobFree.banner.config(bannerConfig);

    this.admobFree.banner.prepare().then(() => {
        // success
    }).catch(e => alert(e));

}



showInterstitialAds(){

    let interstitialConfig: AdMobFreeInterstitialConfig = {
        isTesting: true, // Remove in production
        autoShow: false//,
        //id: "ca-app-pub-3940256099942544/6300978111"
    };

    this.admobFree.interstitial.config(interstitialConfig);

    this.admobFree.interstitial.prepare().then(() => {
      alert("interstitial");
    }).catch(e => alert(e));

}

showRewardVideoAds(){

    let RewardVideoConfig: AdMobFreeRewardVideoConfig = {
        isTesting: true, // Remove in production
        autoShow: false//,
        //id: "ca-app-pub-3940256099942544/6300978111"
    };

    this.admobFree.rewardVideo.config(RewardVideoConfig);

    this.admobFree.rewardVideo.prepare().then(() => {
      alert("rewardVideo");
    }).catch(e => alert(e));

}

I am able to see success alerts in test mode.

#12

I don’t know that plugin, no idea. You should probably open a new issue since it isn’t related to OP original question

#13

Thanks! @reedrichards I have resolved it and explained it in one of my post AdMob in Ionic 4 beta

1 Like
#14

Yes this is the correct answer…have to update the versions of @ionic-native/core and @ionic-native/camera.
Worked for me.

#16

I have also same issue during import import { Base64 } from ‘@ionic-native/base64’; … also I have try adding import { Base64 } from ‘@ionic-native/base64/ngx’; still getting error

#17

i got the same error any idea??

#18

How can I use ionic-native beta 14 ???

#19

Thank you so much…:):blush: