t.resolve is not a function in ionic 4 - ionic-framework

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.

Related

Ionic 4. How change header background color on old android versions

I tried to use css variables for this
ion-toolbar {
--background: #{$backgroundColor3};
--min-height: #{$spacing * 5};
}
All works correct in latest chrome and on android 8. But on adnroid 5 with chrome 40.* it is not worked.
I found that minimal android version for Ionic is 4.4 docs
>ionic info
Ionic:
Ionic CLI : 5.0.1
Ionic Framework : #ionic/angular 4.4.2
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.3.9
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.0, (and 9 other plugins)
Utility:
cordova-res : 0.3.0
native-run : 0.2.5
System:
Android SDK Tools : 26.1.1 (C:\Android)
NodeJS : v11.14.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10
Background is only one problem with styles:
Screenshot with issues from android 5
Normal screenshot
You need to be use add in global or page .scss file
--background: var(--ion-color-primary);
Here your answare.

Ionic live-reload executes twice on save

Every time I make a change to my code, live-reload executes twice. The first reload is quick (< 1 second), then there is a pause, then another reload fires and takes substantially longer (2 - 3 seconds).
When I create a fresh Ionic starter app, I don't get this problem. I have tried different IDEs and get the same result.
My ionic info:
Ionic:
ionic (Ionic CLI) : 4.12.0
Ionic Framework : ionic-angular 3.9.5
#ionic/app-scripts : 3.2.2
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)
System:
Android SDK Tools : 26.1.1 (/Users/alexandrsteinberg/Library/Android/sdk)
ios-deploy : 2.0.0
NodeJS : v8.12.0 (/Users/alexandrsteinberg/.nvm/versions/node/v8.12.0/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001

Ionic: GoogleAnalytics plugin Error: ts: Cannot find name 'GoogleAnalytics'

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';

Ionic serve taking too much time like 4 to 6 minutes while compiling ionic 3 project

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.

Ionic: webpackJsonp is not defined

Ionic app seems to have stopped working and I am not able pinpoint the cause. I started again from blank app, but this error persists
Not sure if I am missing setup steps or issue with version mismatch? any pointers would help as I have wasted weeks on this issue
Accepted answers, like -
WebpackJsonp missing after Ionic 3 update or Ionic 2: ReferenceError: webpackJsonp is not defined have not worked
index.html has
<!-- The polyfills js is generated during the build process -->
<script src="build/polyfills.js"></script>
<!-- The vendor js is generated during the build process
It contains all of the dependencies in node_modules -->
<script src="build/vendor.js"></script>
<!-- The main bundle js is generated during the build process -->
<script src="build/main.js"></script>
ionic info -
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.4.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v9.5.0
npm : 5.7.1
service.worker.js has-
// pre-cache our key assets
self.toolbox.precache(
[
'./build/main.js',
'./build/vendor.js',
'./build/main.css',
'./build/polyfills.js',
'index.html',
'manifest.json'
]
);