I am trying to use Google Analytics plugin on Ionic, the documentation code is not applicable as when I use:
constructor(private ga: GoogleAnalytics)
the editor says "ts: Cannot find name 'GoogleAnalytics'"
however it can see some Object GoogleAnalyticsOriginal instead which compiles but does not work (gives error on runtime).
These are system specs
ionic (Ionic CLI) : 4.5.0
Ionic Framework :
ionic-angular 3.9.2
#ionic/app-scripts : 3.2.1
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-webview 1.1.1, (and 15 other plugins)
System:
NodeJS : v10.13.0 (C:\Program Files\nodejs\node.exe)
npm : 6.5.0
You installed the latest #ionic-native/google-analytics (v5+).
Then you should import GoogleAnalytics from #ionic-native/google-analytics/ngx
import { GoogleAnalytics } from '#ionic-native/google-analytics/ngx';
Or else install #ionic-native/google-analytics with v4+, then you can import GoogleAnalytics from #ionic-native/google-analytics
import { GoogleAnalytics } from '#ionic-native/google-analytics';
Related
I just upgraded capacitor to 3.2.x and when I try to build my Ionic project, almost no capacitor function seems to work. For example, I get errors like:
Uncaught TypeError: cap.nativeCallback is not a function
...
Uncaught TypeError: Capacitor.createEvent is not a function
...
package com.getcapacitor.annotation does not exist
Here's my Ionic Info:
Ionic:
Ionic CLI : 6.17.1 (/usr/local/lib/node_modules/#ionic/cli)
Ionic Framework : #ionic/angular 5.5.2
#angular-devkit/build-angular : 0.1000.8
#angular-devkit/schematics : 10.0.8
#angular/cli : 10.0.8
#ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.0.0-beta.3
#capacitor/core : 3.2.3
#capacitor/ios : not installed
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : android 9.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 9 other plugins)
Utility:
cordova-res : 0.15.3
native-run : 1.4.1
System:
Android SDK Tools : 26.1.1 (/home/che-azeh/Android/Sdk)
NodeJS : v12.21.0 (/usr/bin/node)
npm : 7.5.2
OS : Linux 5.11
Here was the problem: if you look at the capacitor section under my Ionic Info, you'd notice an incosistency between Capacitor CLI, #capaciotr/core and #capacitor/android:
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.0.0-beta.3
#capacitor/core : 3.2.3
So what I did was upgrade all 3 to their latest versions:
npm install #capacitor/cli#latest #capacitor/core#latest
npm install #capacitor/android#latest
Now, it looks ike:
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.2.3
#capacitor/core : 3.2.3
Finally, I remove the Android folder created by capacitor (rm -R ./android), reinitialize capacitor (npx cap init) rebuild ionic project (ionic build android) and then npx cap add android.
And solved! Zero errors!
My use case:
Call JavaScript function from JS file (included in project) in Ionic 4 on particular page.
I'm having following issue.
ERROR TypeError: t.resolve is not a function
at Object.setNativePromise (polyfills.js:3)
at L.configurable.L.set (polyfills.js:3)
at n.exports (ocw.js:4850)
at a (ocw.js:4850)
at Object.209.100 (ocw.js:4851)
at s (ocw.js:4850)
at ocw.js:4850
at Object.327.131 (ocw.js:4852)
at s (ocw.js:4850)
at ocw.js:4850
Steps followed:
Included JS file under src->assets
added reference in index.html after cordova.js file
<!-- cordova.js required for cordova apps (remove if not needed) -->
<!-- <script src="assets/ocw.js"></script> -->
<script src="cordova.js"></script>
<script src="assets/ocw.js"></script>
In desired file, declared variable as function name
called javascript function under, ionViewDidLoad
Ionic setup:
Ionic:
ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 6.4.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.2, (and 9 other plugins)
System:
ios-deploy : 1.9.2
ios-sim : 6.0.0
NodeJS : v8.12.0 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS
Xcode : Xcode 10.1 Build version 10B61
You need to export the function in your javascript file and then import it in your pagename.page.ts to be able to use it.
I'm trying to get the event from an input field but the following error occurs (same error for ngAfterViewInit / ionViewDidEnter):
ERROR TypeError: Invalid event target
at setupSubscription (fromEvent.js:50)
at Observable._subscribe (fromEvent.js:24)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)
at MapOperator.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapOperator.call (map.js:18)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:23)
at PeoplePage.push../src/app/people/people.page.ts.PeoplePage.ionViewDidEnter (people.page.ts:88)
at HTMLElement.handler (angular-delegate.js:101)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3811)
people.page.ts
import {concat, fromEvent, Observable, of, pipe} from 'rxjs';
#ViewChild('searchInput') searchInput: ElementRef;
ionViewDidEnter() {
fromEvent<any>(this.searchInput.nativeElement, 'keyup')
.pipe(
map(ev => ev.target.value)
)
.subscribe(console.log); // <--- The error occurs here.
people.page.html
<ion-input placeholder="Name" #searchInput> </ion-input>
Ionic:
ionic (Ionic CLI) : 4.5.0
Ionic Framework : #ionic/angular 4.0.0-beta.19
#angular-devkit/build-angular : 0.7.5
#angular-devkit/schematics : 0.7.5
#angular/cli : 6.1.5
#ionic/angular-toolkit : not installed
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 7.1.2
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 11 other plugins)
System:
Android SDK Tools : 26.1.1
NodeJS : v11.5.0
npm : 6.5.0
OS : Linux 4.15
I am using ionic-3 and when I am compiling ionic project through ionic serve command, Its taking 4-6 mins for me.
Versions of following components:
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
#ionic/app-scripts : 2.1.4
Cordova Platforms : android 7.1.0
Ionic Framework : ionic-angular 3.7.1
System:
Android SDK Tools : 26.1.1
Node : v7.10.1
npm : 5.4.2
OS : Linux 4.4
Environment Variables:
ANDROID_HOME : /home/spaneos/Android/Sdk
Misc:
backend : pro
node version: 7.10.0
npm version: 5.4.2
It depends on your system specification. If you have a higher config machine then it will take less time. I hope you got the point.
Runtime Error
Module build failed: Error: ENOENT: no such file or directory, open '/Users/.../src/constants/Strings.js.map' at Error (native)
typescript": "2.3.4"
Ionic info
global packages:
#ionic/cli-utils : 1.4.0
Cordova CLI : 7.0.1
Ionic CLI : 3.4.0
local packages:
#ionic/app-scripts : 1.3.7
#ionic/cli-plugin-cordova : 1.4.0
#ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.4.2
System:
Node : v6.10.3
OS : macOS Sierra
Xcode : Xcode 8.3.2 Build version 8E2002
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 5.0.3
reading this post on the official ionic blog it seems like it could be some import that are unmatched because capital letters.
Give it a try, hope this helps you to solve your problem.