I'm trying to implement an authentication functionality using effects. These are the relevant classes
// auth.actions.ts
import { Action } from '#ngrx/store';
import { AuthVM, ParamsVM } from '../models';
import { Credential } from '../interfaces';
export const FETCH_AUTH_INFO = 'FETCH_AUTH_INFO';
export const AUTHENTICATE_WITHOUT_CREDENTIALS = 'AUTHENTICATE_WITHOUT_CREDENTIALS';
export class FetchAuthInfo implements Action {
readonly type = FETCH_AUTH_INFO;
constructor(public payload = undefined) { }
}
export class AuthenticateWithoutCredentials implements Action {
readonly type = AUTHENTICATE_WITHOUT_CREDENTIALS;
constructor(public payload: ParamsVM = undefined) { }
}
export type AuthActions = FetchAuthInfo | AuthenticateWithoutCredentials;
#
// auth.effects.ts
import { Injectable } from "#angular/core";
import { Actions, Effect } from '#ngrx/effects';
import { Observable } from 'rxjs/Observable';
import { Action } from '#ngrx/store';
import * as fromAuthActions from './auth.actions';
import { Storage } from '#ionic/storage';
import { fromPromise } from "rxjs/observable/fromPromise";
import { AuthVM, ParamsVM } from '../models';
import { of } from 'rxjs/observable/of';
import { AuthInfoFetched, AuthenticateWithoutCredentials} from './auth.actions';
#Injectable()
export class AuthEffects {
constructor(
private actions$: Actions,
private storage: Storage
) { }
#Effect() fetchAuthInfo$: Observable<Action> = this.actions$
.ofType(fromAuthActions.FETCH_AUTH_INFO)
.mergeMap(() => fromPromise(this.storage.get('authInfo')))
.mergeMap((data: AuthVM) => {
if (data) {
return of(new AuthInfoFetched(data));
} else {
return of(new AuthenticateWithoutCredentials());
}
});
}
I'm getting this error:
The type argument for type parameter 'R' cannot be inferred from the usage. Consider specifying the type
arguments explicitly. Type argument candidate 'AuthInfoFetched' is not a valid type argument because it is
not a supertype of candidate 'AuthenticateWithoutCredentials'. Types of property 'type' are incompatible.
Type '"AUTHENTICATE_WITHOUT_CREDENTIALS"' is not assignable to type '"AUTH_INFO_FETCHED"'.
As far as I know, an Action Observable should be returned at the end of the operators chain. I can't understand why I'm getting the error since AuthInfoFetched and AuthenticateWithoutCredentials both implement the Action interface.
This is the package.json file if it is of any use
{
"name": "app",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "^4.4.6",
"#angular/compiler": "^4.4.6",
"#angular/compiler-cli": "^4.4.6",
"#angular/core": "^4.4.6",
"#angular/forms": "^4.4.6",
"#angular/http": "^4.4.6",
"#angular/platform-browser": "^4.4.6",
"#angular/platform-browser-dynamic": "^4.4.6",
"#ionic-native/admob-free": "^4.4.2",
"#ionic-native/core": "3.12.1",
"#ionic-native/splash-screen": "3.12.1",
"#ionic-native/status-bar": "3.12.1",
"#ionic/app-scripts": "2.1.3",
"#ionic/storage": "2.0.1",
"#ngrx/effects": "^4.1.1",
"#ngrx/store": "^4.1.1",
"#ngrx/store-devtools": "^4.1.1",
"body-parser": "^1.18.2",
"cordova-admob-sdk": "^0.11.1",
"cordova-android": "^6.4.0",
"cordova-plugin-admob-free": "^0.11.0",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-statusbar": "^2.3.0",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-promise-polyfill": "0.0.2",
"cordova-sqlite-storage": "^2.1.2",
"cors": "^2.8.4",
"express": "^4.16.2",
"ionic-angular": "3.6.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"morgan": "^1.9.0",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"typescript": "2.3.4",
"zone.js": "0.8.12"
},
"devDependencies": {
"ionic": "3.19.1"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-sqlite-storage": {},
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-admob-free": {}
},
"platforms": [
"android"
]
}
}
Any help would be much appreciated.
In the effect you are returning two different types of action using if/else, so the type can not be inferred for the effect. you can use rxjs if operator or use a temp variable. note ngrx now uses pipes with rxjs 6
Here is code showing different ways
//one way
#Effect() fetchAuthInfo$: Observable<Action> = this.actions$
.ofType(fromAuthActions.FETCH_AUTH_INFO)
.map(() => fromPromise(this.storage.get('authInfo')))
.switchMap((data: AuthVM) => {
let result;
if (data) {
result = of(new AuthInfoFetched(data));
} else {
result = of(new AuthenticateWithoutCredentials());
}
return result;
});
//second way
#Effect() fetchAuthInfo$: Observable<Action> = this.actions$
.ofType(fromAuthActions.FETCH_AUTH_INFO)
.map(() => fromPromise(this.storage.get('authInfo')))
.switchMap((data: AuthVM) => Observable.if(() => data,
of(new AuthInfoFetched(data)),
of(new AuthenticateWithoutCredentials())
)
);
//the new effect way in ngrx
#Effect() fetchAuthInfo$ = this.actions$.pipe(
ofType(fromAuthActions.FETCH_AUTH_INFO),
map(() => fromPromise(this.storage.get('authInfo'))),
switchMap((data: AuthVM) => iif(() => data,
of(new AuthInfoFetched(data)),
of(new AuthenticateWithoutCredentials()))
)
);
I also got it working typecasting the returned values to the "Action" type
#Effect() fetchAuthInfo$: Observable<Action> = this.actions$
.ofType(FETCH_AUTH_INFO)
.mergeMap(() => fromPromise(this.storage.get('authInfo')))
.mergeMap((data: AuthVM) => {
if (data) {
return of(<Action>new AuthInfoFetched(data));
} else {
return of(<Action>new AuthenticateWithoutCredentials());
}
});
Related
After doing the install using
npm install echarts -S
npm install ngx-echarts -S
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { HttpClientModule } from '#angular/common/http';
import { MatFormFieldModule, MatIconModule, MatInputModule, MatMenuModule, MatSelectModule } from '#angular/material';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { DashboardComponent } from './pages/dashboard/dashboard.component';
import { PageHeaderComponent } from './components/page-header/page-header.component';
import { ChubbTableComponent } from './components/chubb-table/chubb-table.component';
import { StatusChipComponent } from './components/status-chip/status-chip.component';
import { NgxEchartsModule } from 'ngx-echarts';
#NgModule({
declarations: [
AppComponent,
DashboardComponent,
PageHeaderComponent,
ChubbTableComponent,
StatusChipComponent,
],
imports: [
BrowserModule,
HttpClientModule,
BrowserAnimationsModule,
AppRoutingModule,
MatInputModule,
MatFormFieldModule,
MatSelectModule,
MatIconModule,
MatMenuModule,
NgxEchartsModule.forRoot({
/**
* This will import all modules from echarts.
* If you only need custom modules,
* please refer to [Custom Build] section.
*/
echarts: () => import('echarts'), // or import('./path-to-my-custom-echarts')
})
],
exports: [
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
this is what my app.module.ts looks like. But I get this error below when serving.
{
"name": "modular-ui",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --open",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"#angular/animations": "^14.2.12",
"#angular/cdk": "^7.3.7",
"#angular/common": "^14.0.0",
"#angular/compiler": "^14.0.0",
"#angular/core": "^14.0.0",
"#angular/forms": "^14.0.0",
"#angular/material": "^7.3.7",
"#angular/platform-browser": "^14.0.0",
"#angular/platform-browser-dynamic": "^14.0.0",
"#angular/router": "^14.0.0",
"bootstrap": "^5.2.3",
"bootstrap-icons": "^1.10.3",
"clone-deep": "^4.0.1",
"echarts": "^5.4.1",
"material-components-web": "^14.0.0",
"ngx-echarts": "^15.0.1",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "^14.0.4",
"#angular/cli": "~14.0.4",
"#angular/compiler-cli": "^14.0.0",
"#types/jasmine": "~4.0.0",
"jasmine-core": "~4.1.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.7.2"
}
}
this is my package.json
Error: node_modules/ngx-echarts/lib/ngx-echarts.directive.d.ts:90:18 - error TS2707: Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments.
90 static ɵdir: i0.ɵɵDirectiveDeclaration<NgxEchartsDirective, "echarts, [echarts]", ["echarts"], { "options": "options"; "theme": "theme"; "initOpts": "initOpts"; "merge": "merge"; "autoResize": "autoResize"; "loading": "loading"; "loadingType": "loadingType"; "loadingOpts": "loadingOpts"; }, { "chartInit": "chartInit"; "optionsError": "optionsError"; "chartClick": "chartClick"; "chartDblClick": "chartDblClick"; "chartMouseDown": "chartMouseDown"; "chartMouseMove": "chartMouseMove"; "chartMouseUp": "chartMouseUp"; "chartMouseOver": "chartMouseOver"; "chartMouseOut": "chartMouseOut"; "chartGlobalOut": "chartGlobalOut"; "chartContextMenu": "chartContextMenu"; "chartLegendSelectChanged": "chartLegendSelectChanged"; "chartLegendSelected": "chartLegendSelected"; "chartLegendUnselected": "chartLegendUnselected"; "chartLegendScroll": "chartLegendScroll"; "chartDataZoom": "chartDataZoom"; "chartDataRangeSelected": "chartDataRangeSelected"; "chartTimelineChanged": "chartTimelineChanged"; "chartTimelinePlayChanged": "chartTimelinePlayChanged"; "chartRestore": "chartRestore"; "chartDataViewChanged": "chartDataViewChanged"; "chartMagicTypeChanged": "chartMagicTypeChanged"; "chartPieSelectChanged": "chartPieSelectChanged"; "chartPieSelected": "chartPieSelected"; "chartPieUnselected": "chartPieUnselected"; "chartMapSelectChanged": "chartMapSelectChanged"; "chartMapSelected": "chartMapSelected"; "chartMapUnselected": "chartMapUnselected"; "chartAxisAreaSelected": "chartAxisAreaSelected"; "chartFocusNodeAdjacency": "chartFocusNodeAdjacency"; "chartUnfocusNodeAdjacency": "chartUnfocusNodeAdjacency"; "chartBrush": "chartBrush"; "chartBrushEnd": "chartBrushEnd"; "chartBrushSelected": "chartBrushSelected"; "chartRendered": "chartRendered"; "chartFinished": "chartFinished"; }, never, never, false, never>;
not sure what is wrong as I only followed the simple instructions
i am building bar charts using D3, it runs fine when i run with ionic cordova run/build android but it gives error when i run with --prod mode i.e ionic cordova run/build android --prod. The app opens fine but the bar chart do not draw. The x-axis draws fine but it is unable to draw y- axis. can someone please help. I have attached the image of my error message below. I am stuck in this for the past few days, any help would be really helpful. Thanks in advance
**here is mycode** //
import { Component } from '#angular/core';
import { Platform } from '#ionic/angular';
import * as d3 from 'd3-selection';
import * as d3Scale from 'd3-scale';
import * as d3Array from 'd3-array';
import * as d3Axis from 'd3-axis';
#Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
barData = [
{ season: 'S1', viewers: 250000 },
{ season: 'S2', viewers: 380000 },
{ season: 'S3', viewers: 500000 },
{ season: 'S4', viewers: 690000 },
{ season: 'S5', viewers: 690000 },
{ season: 'S6', viewers: 750000 },
{ season: 'S7', viewers: 1000000 },
{ season: 'S8', viewers: 1700000 }
];
title = 'originals';
subtitle = 'Viewers per season for';
width: number;
height: number;
margin = { top: 20, right: 20, bottom: 30, left: 40 };
x: any;
y: any;
svg: any;
g: any;
constructor(private _platform: Platform) {
this.width = 900 - this.margin.left - this.margin.right;
this.height = 500 - this.margin.top - this.margin.bottom;
}
ionViewDidEnter() {
this.init();
this.initAxes();
this.drawAxes();
this.drawChart();
}
init() {
this.svg = d3.select('#barChart')
.append('svg')
.attr('width', '100%')
.attr('height', '100%')
.attr('viewBox', '0 0 900 500');
this.g = this.svg.append('g')
.attr('transform', 'translate(' + this.margin.left + ',' + this.margin.top + ')');
}
initAxes() {
this.x = d3Scale.scaleBand().rangeRound([0, this.width]).padding(0.1);
this.y = d3Scale.scaleLinear().rangeRound([this.height, 0]);
this.x.domain(this.barData.map((d) => d.season));
this.y.domain([0, d3Array.max(this.barData, (d) => d.viewers)]);
}
drawAxes() {
this.g.append('g')
.attr('class', 'axis axis--x')
.attr('transform', 'translate(0,' + this.height + ')')
.call(d3Axis.axisBottom(this.x))
.attr('font-size', '30');
this.g.append('g')
.attr('class', 'axis axis--y')
.call(d3Axis.axisLeft(this.y))
.append('text')
.attr('class', 'axis-title')
.attr('transform', 'rotate(-90)')
.attr('y', 6)
.attr('dy', '0.71em')
.attr('text-anchor', 'end')
.attr('fill', 'rgb(34, 167, 240)')
.attr('font-size', '50')
.text('viewers');
}
drawChart() {
this.g.selectAll('.bar')
.data(this.barData)
.enter()
.append('rect')
.attr('class', 'bar')
.attr('fill', 'rgb(34, 167, 240)')
.attr('x', (d) => this.x(d.season))
.attr('y', (d) => this.y(d.viewers))
.attr('width', this.x.bandwidth())
.attr('height', (d) => this.height - this.y(d.viewers));
}
}
**pacjage.json**
{
"name": "example",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "~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/android-permissions": "^5.17.1",
"#ionic-native/camera": "^5.17.1",
"#ionic-native/core": "^5.0.0",
"#ionic-native/document-viewer": "^5.17.0",
"#ionic-native/file": "^5.17.0",
"#ionic-native/file-opener": "^5.17.0",
"#ionic-native/file-transfer": "^5.17.0",
"#ionic-native/local-notifications": "^5.17.1",
"#ionic-native/network": "^5.17.0",
"#ionic-native/screen-orientation": "^5.17.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.7.1",
"#ionic/storage": "^2.2.0",
"cordova-android": "8.1.0",
"cordova-browser": "6.0.0",
"cordova-plugin-android-permissions": "^1.0.2",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-document-viewer": "^0.9.13",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^2.2.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-screen-orientation": "^3.0.2",
"cordova-sqlite-storage": "^3.4.0",
"core-js": "^2.5.4",
"d3": "^5.14.2",
"es6-promise-plugin": "^4.2.2",
"jquery": "^3.4.1",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/architect": "~0.801.2",
"#angular-devkit/build-angular": "~0.801.2",
"#angular-devkit/core": "~8.1.2",
"#angular-devkit/schematics": "~8.1.2",
"#angular/cli": "~8.1.2",
"#angular/compiler": "~8.1.2",
"#angular/compiler-cli": "~8.1.2",
"#angular/language-service": "~8.1.2",
"#ionic/angular-toolkit": "^2.1.1",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "^5.0.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"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-network-information": {},
"cordova-sqlite-storage": {},
"cordova-plugin-screen-orientation": {},
"cordova-plugin-document-viewer": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file": {},
"cordova-plugin-file-opener2": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-android-permissions": {},
"cordova-plugin-local-notification": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}
},
"platforms": [
"browser",
"android"
]
}
}
**here is the image of my error message**
[1]: https://i.stack.imgur.com/zs5KM.png
Finally it started working after i added
this.g.append('g')
.call(d3Axis.axisLeft(this.y).tickFormat ((d: any) => {
return d;
})
)
It seemed tickformat is necessary while running in production mode. anyway still thanks.
I've just installed the ionic native calendar plugin for phone gap, based on the instructions here: https://ionicframework.com/docs/v3/native/calendar/
When I call anything like hasWritePermission() I get the following error:
index.js:685 Uncaught TypeError: Object(...) is not a function
at index.js:685
at Module../node_modules/#ionic-native/calendar/index.js (index.js:888)
at __webpack_require__ (bootstrap:83)
at Module../src/app/modals/event-detail-modal/event-detail-modal.component.ts (main.js:2401)
at __webpack_require__ (bootstrap:83)
at Module../src/app/app.module.ts (app.component.ts:13)
at __webpack_require__ (bootstrap:83)
at Module../src/main.ts (main.ts:1)
at __webpack_require__ (bootstrap:83)
at Object.0 (main.ts:12)
I'm using ionic 4 and angular 7, I'm wondering if this is down to unsupported dependencies? If it is, is there a more up to date plugin I can use, or am I doing something wrong here?
CODE: (addToCalendar method at the bottom)
import { Component, OnInit } from '#angular/core';
import {ModalController, NavParams} from "#ionic/angular";
import {ActivatedRoute, ActivatedRouteSnapshot} from "#angular/router";
import {Calendar} from "#ionic-native/calendar";
interface EventsInterface {
title: string;
startTime: Date;
endTime: Date;
ID: number;
categoriesString: string;
description: string;
recurring: boolean;
recurFrequency: string;
thumbnail: string;
}
#Component({
selector: 'app-event-detail-modal',
templateUrl: './event-detail-modal.component.html',
styleUrls: ['./event-detail-modal.component.scss'],
})
export class EventDetailModalComponent implements OnInit {
/**
*
*/
public event: EventsInterface = null;
/**
*
* #param modalController
* #param navParams
*/
constructor(private calendar: Calendar,private modalController: ModalController, private navParams: NavParams) { }
/**
*
* #param route
*/
ngOnInit() {
// get the event
this.event = <EventsInterface>this.navParams.get('event');
console.log(this.event);
}
/**
*
*/
dismiss(){
return this.modalController.dismiss({
'dismissed':true
});
}
addToCalendar(event: EventsInterface){
this.calendar.hasWritePermission().then((resp: any)=>{
console.log(resp)
}).catch((resp: any) =>{
console.log(resp);
});
}
}
As you can see, I've done very little so far execpt install the plugins and setup a simple promise catch...
EDIT
p
It appears to be related to the wrong versions of some libraries, when installing with nom it warns:
npm WARN #ionic-native/calendar#4.20.0 requires a peer of #ionic-native/core#^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN #ionic-native/calendar#4.20.0 requires a peer of rxjs#^5.5.11 but none is installed. You must install peer dependencies yourself.
The problem with this is the rest of the app is using ionic native 5.0.0 and rxjs 6.5.1 and for some reason the calendar component won't work with these newer versions?
Here is the package file:
{
"name": "V3",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.15",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#ionic-native/calendar": "^4.20.0",
"#ionic-native/core": "^5.0.0",
"#ionic-native/in-app-browser": "^5.12.0",
"#ionic-native/native-page-transitions": "^5.8.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.1.0",
"#ionic/storage": "^2.2.0",
"#types/jquery": "^3.3.31",
"chart.js": "^2.8.0",
"cordova-ios": "4.5.5",
"cordova-plugin-calendar": "^5.1.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-inappbrowser": "^3.1.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^3.2.0",
"core-js": "^2.5.4",
"intl": "^1.2.5",
"ion4-calendar": "^3.0.4-beta.17",
"ionic2-calendar": "^0.5.2",
"jquery": "^3.4.1",
"moment": "^2.24.0",
"ng2-file-upload": "^1.3.0",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "~7.3.8",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.5.1",
"#types/node": "~12.0.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"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": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-sqlite-storage": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-calendar": {
"CALENDAR_USAGE_DESCRIPTION": " ",
"CONTACTS_USAGE_DESCRIPTION": " "
}
},
"platforms": [
"ios"
]
}
}
I am trying to deploy my ionic app to appstore. But I cant able to build this app to --prod. There is no error while deploying for test build. Please help me to fix this.
I was working with ionic 3 framework. I created a calendar app. This is my first app so I have no idea to fix this. I am getting error while running the following command
ionic cordova build ios --prod.
Here is my app module
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { RouteReuseStrategy } from '#angular/router';
import { IonicModule, IonicRouteStrategy } from '#ionic/angular';
import { SplashScreen } from '#ionic-native/splash-screen/ngx';
import { StatusBar } from '#ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '#angular/common/http';
import { IonicStorageModule, Storage } from '#ionic/storage';
import { JwtModule, JWT_OPTIONS, JwtHelperService } from '#auth0/angular-jwt';
import { HTTP } from '#ionic-native/http/ngx';
import { ReactiveFormsModule, FormsModule } from '#angular/forms';
import { CommonModule } from '#angular/common';
import { LoginPage } from './login/login.page';
import { HomePage } from './home/home.page';
import { UpdateEventPage } from './home/update-event/update-event.page';
import { AddMembersComponent } from './home/add-members/add-members.component';
import { ProfilePage } from './profile/profile.page';
import { NgCalendarModule } from 'ionic2-calendar';
import { IonicSelectableModule } from 'ionic-selectable';
export function jwtOptionsFactory(storage) {
return {
tokenGetter: () => {
return storage.get('access_token');
},
whitelistedDomains: ['82.165.76.209:57', 'localhost:8100']
}
}
#NgModule({
declarations: [AppComponent, LoginPage, HomePage, UpdateEventPage, AddMembersComponent, ProfilePage],
entryComponents: [UpdateEventPage, AddMembersComponent],
imports: [
BrowserModule,
IonicModule.forRoot(),
IonicStorageModule.forRoot(),
HttpClientModule,
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
NgCalendarModule,
IonicSelectableModule,
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [Storage],
}
}),
AppRoutingModule,
],
providers: [
StatusBar,
SplashScreen,
JwtHelperService,,
HTTP,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
This is my package json dependencies
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.2",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#auth0/angular-jwt": "^2.1.0",
"#capacitor/android": "^1.0.0-beta.19",
"#capacitor/cli": "1.0.0-beta.19",
"#capacitor/core": "1.0.0-beta.19",
"#ionic-native/core": "^5.0.0",
"#ionic-native/http": "^5.5.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.5.0",
"#ionic/angular": "^4.1.0",
"#ionic/pro": "2.0.4",
"#ionic/storage": "^2.2.0",
"cordova-android": "8.0.0",
"cordova-ios": "5.0.1",
"cordova-plugin-advanced-http": "2.0.9",
"cordova-plugin-file": "6.0.1",
"cordova-sqlite-storage": "3.2.0",
"core-js": "^2.5.4",
"ionic-selectable": "^4.4.0",
"ionic2-calendar": "^0.5.2",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "~7.3.8",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.5.1",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~10.14.2",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"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": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "~3.1.6"
},
I am getting the following error.
ERROR in src\app\app.module.ts(60,22): Error during template compile of 'AppModule'
Expression form not supported.
[ERROR] An error occurred while running subprocess ng.
On line 60 you have a typo:
JwtHelperService,,
Change this to:
JwtHelperService,
Plugin:
cordova plugin add cordova-plugin-networkinterface
Code:
networkinterface.getIpAddress((ip) => {
console.log(ip);
});
Error:
TypeError: Cannot read property 'getIPAddress' of undefined
Now here neither I have provide any provider nor any import, so how does it work in ionic 2 ?
It's not A native plugin. But this plugin is working in ionic 2 also according to this link
Package.json :
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "2.4.8",
"#angular/compiler": "2.4.8",
"#angular/compiler-cli": "2.4.8",
"#angular/core": "2.4.8",
"#angular/forms": "2.4.8",
"#angular/http": "2.4.8",
"#angular/platform-browser": "2.4.8",
"#angular/platform-browser-dynamic": "2.4.8",
"#angular/platform-server": "2.4.8",
"#ionic-native/core": "3.1.0",
"#ionic-native/in-app-browser": "^3.4.2",
"#ionic-native/network": "^3.4.2",
"#ionic-native/splash-screen": "3.1.0",
"#ionic-native/status-bar": "3.1.0",
"#ionic-native/toast": "^3.4.4",
"#ionic/app-scripts": "^1.2.2",
"#ionic/storage": "2.0.0",
"ionic-angular": "2.3.0",
"ionic-native": "^2.9.0",
"ionicons": "3.0.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2"
},
"devDependencies": {
"#ionic/app-scripts": "1.2.2",
"typescript": "2.0.9"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-statusbar",
"cordova-plugin-console",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [],
"description": "Test"
}
Latest Code File :
declare var networkinterface: any;
#Component({
templateUrl: 'app.html'
})
export class MyApp {
public rootPage:any = HomePage;
constructor(private platform: Platform,private statusBar: StatusBar,private splashScreen: SplashScreen, private network: Network, private iab: InAppBrowser, private http: Http, private toast: Toast) {
platform.ready().then(() => {
networkinterface.getWiFiIPAddress((ip) => {
console.log(ip);
});
}
You have to use it like below after installing the non-native plugin.
This method (getIpAddress()) is deprecated and uses the
getWiFiIPAddress() method.
declare let networkinterface: any;
#Component({
...
})
export class TestPage {
...
getIpAddress() {
networkinterface.getWiFiIPAddress((ip) => {
console.log(ip);
});
}
}
You can try using external url:
async function getIP(){
const repsIP = await fetch('https://api.ipify.org/?format=json');
const data = await repsIP.json();
return data;
}
Wherever you want, call this function:
this.getIP().then(data => this.ipAddress = data.ip);