I have the following code using Ionic Native Geolocation:
import { Geolocation } from 'ionic-native';
this.platform.ready().then(() => {
alert('loadMap about to getCurrentPosition');
Geolocation.getCurrentPosition(options).then((position) => {
alert('loadMap getCurrentPosition');
let latLng: google.maps.LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
bound.extend(latLng);
this.load(bound);
});
});
When I run this as ionic serve in a browser, or I build it and run it on iOS Simulator (Xcode), it works. However, when I build this for Android, and try run it, the first alert gets fired, but not the second.
That means for Android only, Geolocation.getCurrentPosition... is not working.
I do have another page that can render a map via this.map = new google.maps.Map(htmlElement, mapOptions);, so it looks like the issue is with getting the current position. When I install the app, I do get this message however:
Allow AppName to access the device's location?
DENY ALLOW
To which I click Allow.
Does anyone know what I am doing incorrectly, or if there are some missing steps in the Android install and build process?
Thanks
Ok, so I have struggled with this for a while now. Some times it works, some times it does not. Try to add options to it:
let options = {timeout: 10000, enableHighAccuracy: true, maximumAge: 3600};
Geolocation.getCurrentPosition(options).then((resp) => {
These following steps did the trick for me:
Install the two latest ionic-cli plugins:
sudo npm install -g ionic#latest
npm install --save-dev --save-exact #ionic/cli-plugin-cordova#latest
npm install --save-dev --save-exact #ionic/cli-plugin-ionic-angular#latest
Then install the geolocation plugin:
npm install #ionic-native/geolocation --save
ionic cordova plugin add cordova-plugin-geolocation
Then remove the '/node_modules' folder and clean the cache of npm:
rm -rf node_modules/
npm cache clean --force
And finally reinstall the packages:
npm install
Hope it will help someone :)
let options = {timeout: 10000, enableHighAccuracy: true, maximumAge: 3600};
this seem run the geolocation but can not catch the lat and lng return {}
Try Background Geolocation instead of Geolocation it solved my problem
for more detail read the document
https://ionicframework.com/docs/native/background-geolocation/
Related
I am native iOS app developer but i also want to be aware of latest and trending technology so i choose to get my hands on react native. Now, i am getting this error when trying to run my react native created app on iOS. I enter the command react-native run-ios and simulator started and after that app opened but in starting it showed this screen.
There are couple of solutions available in the link below. Please try them.
https://github.com/facebook/react-native/issues/21310
for now after react-native init, since a lot of new changes are coming out, this fix worked for me (I got it from reading other issues):
with npm:
npm install --save-dev #babel/core
npm install --save-dev #babel/runtime
or with yarn:
yarn add --dev #babel/core
yarn add --dev #babel/runtime
if on ios you get _this._registerEvents is not a function, after a successful build
do
npm run start --reset-cache
or
react-native start --reset-cache
For me i got reason for issues that for now since a lot of new changes are coming out like Xcode 10 itself is new and react native is not yet merged with that, this fix worked for me:
with npm:
npm install --save #babel/runtime
or with yarn:
yarn add #babel/runtime
After days of research on the internet I still haven't solved my problem yet.
I am using react-native-svg and I am having the same issues:
No component found for view with the name "RNSVGPath"
Or this one:
Invariant Violation: Native component for "RNSVGSvgView" does not exist
I tried a lot of things, including:
react-native unlink react-native-svg
npm uninstall react-native-svg
npm install react-native-svg
react-native link react-native-svg
react-native run-ios
Also:
pod 'RNSVG', :path => '../node_modules/react-native-svg'
rm -rf node_modules
npm install
react-native run-ios
But still nothing...
Here's the versions I am using:
"dependencies": {
"react": "16.1.1",
"react-native": "0.50.3",
"react-native-svg": "^6.0.1-rc.1"
}
I tried to build it from XCode directly and still nothing...
Thanks for your help guys !
You should try to do this:
npm install react-native-svg --save //(again)
react-native link react-native-svg //(again)
watchman watch-del-all
rm -rf node_modules/ && yarn cache clean && yarn install
Then in another terminal
npm start -- --reset-cache
Before starting your ios app with react-native run-ios, you have to add libRNSVG.a manually to your Linked Frameworks and Libraries in Xcode
And then ... Tada
SVG Problem, I also stuffed 4 hours and get the solution.
Automatic link:
react-native link react-native-svg
Does not work automatically then you do with manually.
Manual Link:
1 Append the following lines to android/settings.gradle:
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
2 Insert the following lines inside the dependencies block in android/app/build.gradle:
implementation project(':react-native-svg')
3 Open up `android/app/src/main/java/[...]/MainApplication.java
Add import com.horcrux.svg.SvgPackage; to the imports at the top of the file.
Add new SvgPackage() to the list returned by the getPackages() method. Add a comma to the previous item if there's already something there.
I had this problem because "react-native link" is broken as of RN 0.51. Linking manually after complete removal and reinstall fixed it on iOS.
Svg have problem with version
first, unlink svg then remove npm of svg then install new one
"dependencies": {
"react": "16.1.1",
"react-native": "0.44.0",
"react-native-svg": "5.1.8"
}
I had the same issue but on Android.
So, if you are in the same conditions, here is something that fixed it, the trouble happened specifically on MainApplication, so you want to look at :
open android/app/src/java/com/*/MainApplication.java
add import com.horcrux.svg.SvgPackage; on top with other imports
add new SvgPackage() along the others in the list getPackages() (~line 30-ish)
I have a simple react app. It uses:
react
webpack
redux
css-modules
Was looking for an easy way to wrap a React app into Electron.
Am trying out webview
Have a simple electron app
It works on OSX but not on Windows 10,
Please help.
It opens up the Electron app but nothing is visible in the webview
I have opened devtools in both the Electron renderer process and the webview,
but i do not see any error messages
I have tried:
electro-forge
electron and electron-packager
steps to run the app
install the global dependencies:
install node LTS ie. v6.9.2
install electron-forge with "npm install -g electron-forge"
run the React app:
git clone https://github.com/deepak/react-todo
cd react-todo
npm install
npm start
open "http://localhost:3000/todo" and "http://localhost:3000/" on the browser and checks that it works
run the Electron app:
git clone https://github.com/deepak/electron-webview-todo
cd electron-webview-todo
npm install
npm start (works on OSX but not windows 10)
we are using electron-forge here
try the same with plain Electron at the use-electron-packager-and-not-electron-forge branch
I was loading "http://0.0.0.0:3000"
It works when i load "http://localhost:3000/" instead
I am currently upgrading to the most recent version of react from 0.11.0 branch.
I have upgraded successfully through each step with minimal issues but when I got to 0.14.0 I hit some issues with:
node_modules/react-native/packager/react-native-xcode.sh
No matter what I do all my machines seem to get this same error.
Command `bundle` unrecognized. Did you mean to run this inside a react-native project?
I also run this same command that script runs from my terminal in the same location and it works fine, I have also set the path as well and before the script runs no mas, set path inside the script still nothing.
I am hoping someone else has saw this and has found a solution or is there a work around so we dont need this script.
I started this project with react-native ~0.6.0 maybe even a little earlier.
I have even removed nvm to combat this issue and using single install of node which is on PATH in both conditions.
Thanks!
Have you installed the latest version of react-native-cli globally?
npm uninstall -g react-native-cli
npm install -g react-native-cli
I personally preferred to install it as a dev dependency.
yarn add -D react-native-cli
i am building an app that uses react-router,flux and i found this library called redux-auth(https://github.com/lynndylanhurley/redux-auth). I am trying to use it since it has a lot of work done regarding loging,sign up, etc.
I installed the dependencies with npm in this order - >
npm install redux-auth --save
npm install material-ui --save
npm install react-tap-event-plugin
After this i got the error i mention, the module isActive cannot be found.
So i searched the web and found this post:
https://github.com/acdlite/redux-router/issues/111
Where they fix it with this command: npm install --save history react-router#latest followed by npm install --save redux-router#1.0.0-beta3
After this my app broke, and now i get the error : "Error: ajax not supported in this browser" when prerendering Router with / and {}
The line with such error: <%= react_router 'Router', 'HistoryLocation', {}, { prerender: params[:noprerender].nil?, prerender_location: root_path } %>
Tried uninstalling such libraries but didn't work out, tried removing the node_modules dir and rebuilding with npm but didn't work.
Any help or advice? is impossible for me to use this library? is it maybe a compability problem between flux and redux? Any help is welcome.
Edit #1 : I am using Chrome.