Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic + Cordova + Angular 16 - Cordova HMS Location #176

Open
Burnie777 opened this issue Apr 16, 2024 · 3 comments
Open

Ionic + Cordova + Angular 16 - Cordova HMS Location #176

Burnie777 opened this issue Apr 16, 2024 · 3 comments

Comments

@Burnie777
Copy link

Burnie777 commented Apr 16, 2024

Description
I am trying to add the location services to get a GPS location in the app, but I am not able to get the correct linking. Based on the Hauweis dev site The ionic native support is optional, however I believe that it not.

My app is running on ionic 7 with Angular 16, and rxJS 7.8.1.

Also, as ionic is no longer maintaining the @ionic-native plugins, I moved everything over to the @awesome-cordova-plugins. I did also notice on the demo code that Angular 15 was used...

Expected behavior
I expect to get location.

Current behavior
After force installing @ionic-native/core (which is Max rxJS 6.5.5):

ERROR Error: Uncaught (in promise): TypeError: n.location.checkLocationPermissions is not a function
TypeError: n.location.checkLocationPermissions is not a function

checkLocationPermissions is a method I created to get locations (which includes the android and ios version as well, as I am doing multi-platform

If @ionic-native/core is not installed, I get a error on build, which says that @ionic-native/core is not found...

Logs

./plugins/cordova-plugin-hms-location/ionic-native/dist/ngx/index.js:18:0-64 - Error: Module not found: Error: Can't resolve '@ionic-native/core' in '/Volumes/TOSHIBA/GitHub/payroll-app-ionic7/plugins/cordova-plugin-hms-location/ionic-native/dist/ngx'


[ERROR] An error occurred while running subprocess ng.
        
        ng run app:ionic-cordova-build --platform=android exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.
bernard@Bernards-Mini payroll-app-ionic7 %  npm install @ionic-native/core @hmscore/ionic-native-hms-location

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~7.8.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^5.5.0 || ^6.5.0" from @ionic-native/[email protected]
npm ERR! node_modules/@ionic-native/core
npm ERR!   @ionic-native/core@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/bernard/.npm/_logs/2024-04-16T13_01_15_048Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/bernard/.npm/_logs/2024-04-16T13_01_15_048Z-debug-0.log

Environment

Ionic:

   Ionic CLI                     : 7.2.0 
   Ionic Framework               : @ionic/angular 7.8.4
   @angular-devkit/build-angular : 16.1.2
   @angular-devkit/schematics    : 16.1.3
   @angular/cli                  : 16.1.3
   @ionic/angular-toolkit        : 10.0.0

Cordova:

   Cordova CLI       : 12.0.0 ([email protected])
   Cordova Platforms : android 12.0.1, ios 6.3.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 12 other plugins)

Utility:

   cordova-res : 0.15.4
   native-run  : 2.0.1

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 1.12.2
   ios-sim           : 8.0.2
   NodeJS            : v18.19.0 
   npm               : 10.2.3
   OS                : macOS Unknown
   Xcode             : Xcode 15.0 Build version 15A240d
   
   rxJS: 7.8.1

Other
This is the first time that we are trying to implement the plugin to ionic 7, angular 16...

@Burnie777 Burnie777 changed the title Ionic + Cordova + Ionic + Cordova + Angular 16 - Cordova HMS Location Apr 16, 2024
@Burnie777
Copy link
Author

I also now tried install only @hmscore/ionic-native-hms-location (without @ionic-native/core) and this also gave the same issue...

ERROR Error: Uncaught (in promise): TypeError: n.location.checkLocationPermissions is not a function
TypeError: n.location.checkLocationPermissions is not a function

@AntonERG
Copy link

@Burnie777 Had same (and more) issues with my capacitor not ionic app and all hms-cordova-plugins, but finally made it work 🥳

Soliton:

#1 Install @ionic-native/core (I did it for my Vuejs + Capacitor, non-ionic app)

npm i @ionic-native/core

#2 Import methods in the app this way:

import { HMSLocation} from '@hmscore/cordova-plugin-hms-location/ionic-native/dist';

P.S. Probably the next issue you will face - will be 'geolocation permission denied'. This plugin will not work if you will grant 'Allow while using the app' permission, you should send user to the app settings and grant 'Allow all the time'

@Burnie777
Copy link
Author

@AEiosApp I am working with Cordova + AngularJS, and not Capacitor...

I have tried to install @ionic-native/core, it give me an error that a function I defined does not exist...

Cordova moved away from @ionic-native/core in Ionic/7, in favour of @awesome-cordova-plugins/core...

Installing the @ionic-native/core, causes limitations and breaks in the newer Ionic Cordova apps...

I am also running Angular 16, whereas the demos run on Angular 15...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants