Related
I am trying to use geoman-io plugin (https://github.com/geoman-io/leaflet-geoman) in ngx-leaflet application. I've found this post: Integrate EasyButton, Geoman with ngx-leaflet , but the only solution provided in this post, that works for me, is to use bracket notation like that:
map["pm"]["addControls"]({position: 'topleft'});
I guess that's not the best way to do this. So my question is how to properly use geoman-io in ngx-leaflet?
When i tried exactly these steps, it doesn't work, because at map.pm.addControls({...}) i get error
Property 'pm' does not exist on type 'Map'
Steps:
npm i #geoman-io/leaflet-geoman-free
Import geoman in the component import '#geoman-io/leaflet-geoman-free';
In angular.json in "build" section import geoman styles:
"styles": [
"src/styles.scss",
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/#geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css"
],
my component:
import { BaseIconOptions, geoJSON, Bounds, CRS, Icon, icon, IconOptions, imageOverlay, latLng,
LatLngBounds, LatLngBoundsExpression, layerGroup, Map, marker, point, polyline, tileLayer } from 'leaflet';
import * as L from 'leaflet';
import 'leaflet-rotatedmarker';
import '#geoman-io/leaflet-geoman-free';
#Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent {
...
onMapReady(map: Map) {
map.pm.addControls({
position: 'topleft',
drawMarker: false
});
}
}
My package.json file:
"dependencies": {
"#angular/animations": "~10.2.0",
"#angular/cdk": "^10.2.7",
"#angular/common": "~10.2.0",
"#angular/compiler": "~10.2.0",
"#angular/core": "~10.2.0",
"#angular/flex-layout": "^10.0.0-beta.32",
"#angular/forms": "~10.2.0",
"#angular/material": "^10.2.7",
"#angular/platform-browser": "~10.2.0",
"#angular/platform-browser-dynamic": "~10.2.0",
"#angular/router": "~10.2.0",
"#asymmetrik/ngx-leaflet": "^8.1.0",
"#fortawesome/angular-fontawesome": "^0.7.0",
"#geoman-io/leaflet-geoman-free": "^2.7.0",
"#types/leaflet": "^1.5.19",
"#types/leaflet-rotatedmarker": "^0.2.1",
"leaflet": "^1.7.1",
"leaflet-rotatedmarker": "^0.2.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.1002.0",
"#angular/cli": "~10.2.0",
"#angular/compiler-cli": "~10.2.0",
"#types/node": "^12.11.1",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
If i change the the onMapReady function to onMapReady(map: L.Map) , it throws the same error. Thanks for help!
For me it works with the dirty type any:
onMapReady(map: any)
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,
import { Component, OnInit, ViewChild } from '#angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '#angular/forms';
import { ModalController, NavParams } from '#ionic/angular';
import { SelecttopicPage } from '../selecttopic/selecttopic.page';
import { ActionSheetController } from '#ionic/angular';
import { Platform } from '#ionic/angular';
import { Storage } from '#ionic/storage';
import { MediaCapture, MediaFile, CaptureError, CaptureVideoOptions } from '#ionic-native/media-capture';
import { Media } from '#ionic-native/media';
import { File } from '#ionic-native/file';
import { Diagnostic } from '#ionic-native/diagnostic';
import { AndroidPermissions } from '#ionic-native/android-permissions';
const MEDIA_FILES_KEY = 'mediaFiles';
#Component({
selector: 'app-uploadvid',
templateUrl: './uploadvid.page.html',
styleUrls: ['./uploadvid.page.scss'],
})
export class UploadvidPage implements OnInit {
#ViewChild('myvideo') myVideo: any;
//uploadVid: FormGroup;
public filePath: string;
public mediaFiles = [];
public isAndroid: boolean;
uploadVid = new FormGroup({
title: new FormControl('', Validators.required),
topic: new FormControl({value: '', disabled: true}, Validators.required),
target: new FormControl('', Validators.required)
});
PERMISSION = {
WRITE_EXTERNAL: this.diagnostic.permission.WRITE_EXTERNAL_STORAGE,
READ_EXTERNAL: this.diagnostic.permission.READ_EXTERNAL_STORAGE,
CAMERA: this.diagnostic.permission.CAMERA,
};
constructor(public formBuilder: FormBuilder,
public modalCtrl: ModalController,
public platform: Platform,
public actionSheetController: ActionSheetController,
public storage: Storage,
public mediaCapture: MediaCapture,
public media: Media,
public file: File,
private diagnostic: Diagnostic,
private androidPermissions: AndroidPermissions) {
// this.uploadVid = formBuilder.group({
// title: ['', Validators.compose([Validators.required])],
// topic: ['', Validators.compose([Validators.required])],
// target: ['', Validators.compose([Validators.required])]
// });
}
ngOnInit() {
this.checkIfMobile();
}
loadStoredVideo(){
this.storage.get(MEDIA_FILES_KEY).then(res => {
this.mediaFiles = JSON.parse(res) || [];
});
}
checkIfMobile(){
if(this.platform.is('android')){
this.isAndroid = true;
}else{
this.isAndroid = false;
}
}
async openModal() {
const modal = await this.modalCtrl.create({
component: SelecttopicPage,
//componentProps: { value: 123 }
});
modal.onDidDismiss((topic) => {
console.log("topic2: "+topic);
this.uploadVid.controls['topic'].setValue(topic);
})
return await modal.present();
}
// for web & ios
handleFileSelect(evt){
this.filePath = evt.target.files;
alert("Selected Video: "+this.filePath);
}
// for android
async openVidOption() {
const actionSheet = await this.actionSheetController.create({
header: "Albums",
buttons: [{
text: 'Camera',
role: 'destructive',
icon: 'camera',
handler: () => {
console.log('Delete clicked');
}
}, {
text: 'Gallery',
role: 'cancel',
icon: 'folder-open',
handler: () => {
console.log('Cancel clicked');
}
}]
});
await actionSheet.present();
}
checkAndroidPerm(){
if(this.platform.is('android')){
//this.requestAllPermissions();
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.CAMERA).then(
(success) => {console.log('Succes granted the permissions');
this.captureVideo()},
(err) => {this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA)}
);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.diagnostic.permission.WRITE_EXTERNAL_STORAGE, this.diagnostic.permission.WRITE_EXTERNAL_STORAGE]);
}
}
// requestAllPermissions(){
// const permissions = Object.keys(this.PERMISSION).map(k => this.PERMISSION[k]);
// this.diagnostic.requestRuntimePermissions(permissions).then((status) => {
// alert(JSON.stringify(status));
// }, error => {
// alert('Error: '+ error);
// });
// }
captureVideo(){
let options: CaptureVideoOptions = {
limit: 1,
duration: 30
}
this.mediaCapture.captureVideo(options).then((res: MediaFile[]) => {
//this.storeMediaFiles(res);
let capturedFile = res[0];
console.log('capturedFile: '+capturedFile);
let fileName = capturedFile.name;
let dir = capturedFile['localURL'].split('/');
dir.pop();
let fromDirectory = dir.join('/');
let toDirectory = this.file.dataDirectory;
this.file.copyFile(fromDirectory, fileName, toDirectory, fileName).then(res => {
let url = res.nativeURL.replace(/^file:\/\//, '');
this.storeMediaFiles([{name: fileName, size: capturedFile.size, localURL: url}]);
});
});
}
storeMediaFiles(files){
this.storage.get(MEDIA_FILES_KEY).then(res =>{
if(res){
let arr = JSON.parse(res);
arr = arr.concat(files);
this.storage.set(MEDIA_FILES_KEY, JSON.stringify(arr));
}else{
this.storage.set(MEDIA_FILES_KEY, JSON.stringify(files));
}
this.mediaFiles = this.mediaFiles.concat();
})
}
playFile(myFile){
console.log('play: ', myFile);
let video = this.myVideo.nativeElement;
video.src = myFile.localURl;
}
}
I am new in Ionic and was working on video capture functionality from this tutorial. When I build android apk and opened the app I got blank screen. So I checked in computer browser and got error as shown in screenshot. I tried to search for its solution and found this posts Link1 and Link2 but this also did not resolved my issue.
If anyone can help me in this regard, it would be good. Thanks in advance.
// config.xml
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^2.0.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-sqlite-storage" spec="^2.3.3" />
<plugin name="cordova-plugin-filechooser" spec="^1.0.1" />
<plugin name="cordova-plugin-filepicker" spec="^1.1.5" />
<plugin name="cordova-plugin-filepath" spec="^1.4.2" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="cordova-plugin-file" spec="^6.0.1" />
<plugin name="cordova-plugin-media" spec="^5.0.2">
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<plugin name="cordova.plugins.diagnostic" spec="^4.0.8" />
<engine name="ios" spec="4.5.5" />
<engine name="android" spec="7.0.0" />
<plugin name="cordova-plugin-media-capture" spec="^3.0.2" />
// package.json
"dependencies": {
"#angular/common": "6.0.9",
"#angular/core": "6.0.9",
"#angular/forms": "6.0.9",
"#angular/http": "6.0.9",
"#angular/platform-browser": "6.0.9",
"#angular/platform-browser-dynamic": "6.0.9",
"#angular/router": "6.0.9",
"#ionic-native/android-permissions": "^4.12.0",
"#ionic-native/core": "5.0.0-beta.14",
"#ionic-native/diagnostic": "^4.12.0",
"#ionic-native/file": "^4.12.0",
"#ionic-native/file-chooser": "^4.12.0",
"#ionic-native/file-path": "^4.12.0",
"#ionic-native/media": "^4.12.0",
"#ionic-native/media-capture": "^4.12.0",
"#ionic-native/splash-screen": "5.0.0-beta.14",
"#ionic-native/status-bar": "5.0.0-beta.14",
"#ionic/angular": "4.0.0-beta.0",
"#ionic/lab": "^1.0.2",
"#ionic/ng-toolkit": "1.0.0",
"#ionic/schematics-angular": "1.0.1",
"#ionic/storage": "^2.1.3",
"angular-progress-http": "^1.0.0",
"cordova-android": "7.0.0",
"cordova-ios": "4.5.5",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-filechooser": "^1.0.1",
"cordova-plugin-filepath": "^1.4.2",
"cordova-plugin-filepicker": "^1.1.5",
"cordova-plugin-ionic-keyboard": "^2.1.2",
"cordova-plugin-ionic-webview": "^2.0.2",
"cordova-plugin-media": "^5.0.2",
"cordova-plugin-media-capture": "^3.0.2",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.3.3",
"cordova.plugins.diagnostic": "^4.0.8",
"core-js": "^2.5.3",
"rxjs": "^6.2.2",
"rxjs-compat": "^6.2.2",
"zone.js": "^0.8.26"
},
"devDependencies": {
"#angular/cli": "6.0.8",
"#angular/compiler": "6.0.9",
"#angular/compiler-cli": "6.0.9",
"#angular/language-service": "6.0.9",
"#angular-devkit/architect": "0.7.0-rc.3",
"#angular-devkit/build-angular": "0.7.0-rc.3",
"#angular-devkit/core": "0.7.0-rc.3",
"#angular-devkit/schematics": "0.7.0-rc.3",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~10.5.2",
"codelyzer": "~4.4.2",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.2",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.7.2"
}
All I had to do was:
In dependencies, instead of "#ionic-native/media-capture": "^4.12.0" I wrote "#ionic-native/media-capture": "^5.0.0-beta.14". After that I typed npm update in CLI. And in my page component I used import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '#ionic-native/media-capture/ngx';. The important part here is /ngx as described in this link. Well I had to do this for AndroidPermissions, Diagnostic, Media and File. After that issue was solved. Hope it will help others.
solved by installing
npm install --save #ionic-native/media-capture#4.20.0
guys, I am building a project with ionic 4 + angular 7, I'm trying to use ionic file system on my project,
https://ionicframework.com/docs/native/file/
following this page, after installing all dependencies when I try to import "File" into my "appModule.ts" I get this error:
Uncaught TypeError: Object(...) is not a function at vendor.js:85920 at Module../node_modules/#ionic-native/native_plugin/index.js
// native_plugin = any native component
fix the issues, with:
npm i -s #ionic-native/xxx#5.0.0-beta.14
Use Angular 6 and 6+ version
import { xxx } from '#ionic-native/xxx/ngx
import { file } from '#ionic-native/file/ngx';
without using Angular
import { xxx } from '#ionic-native/xxx';
import { file } from '#ionic-native/file';
Lastly check the #ionic-native/xxx versions on npm:
https://www.npmjs.com/package/#ionic-native/xxx
https://www.npmjs.com/package/#ionic-native/file
you have to use the version 5.x.x for ANGULAR and 4.x.x ANGULAR-IONIC.
Check your project type on your ionic.config.json file
If use you Ionic v4, use should strictly only use ionic native v5 beta. In your package.json I see that one signal is on v4.12.2 which is not correct, you should upgrade it to v5.0.0-beta.15
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);