This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-12
Channels
- # beginners (102)
- # boot (5)
- # cider (1)
- # cljs-dev (15)
- # cljsjs (1)
- # cljsrn (20)
- # clojure (104)
- # clojure-austin (1)
- # clojure-europe (8)
- # clojure-italy (39)
- # clojure-nl (17)
- # clojure-spec (38)
- # clojure-uk (23)
- # clojurescript (34)
- # cursive (31)
- # data-science (5)
- # datomic (3)
- # emacs (28)
- # joker (1)
- # kaocha (5)
- # klipse (1)
- # leiningen (1)
- # off-topic (66)
- # quil (4)
- # reagent (35)
- # ring-swagger (1)
- # rum (1)
- # shadow-cljs (121)
- # test-check (1)
- # tools-deps (33)
- # uncomplicate (2)
- # vim (15)
- # yada (1)
in react native, i access the global data global.HermesInternal like this (.-HermesInternal js/global), but the console shows that ReferenceError: global is not defined
@titov the same way you would get it with JS React Native. Look at http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/ it’s a bit outdated though in terms of accessing javascript objects. For that you can check: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
I'm trying to import js module inside my app with this code:
(def Geolocation (js/require "react-native-geolocation-service"))
and it says there is no such module, although I have installed it with npm
. It's so strange cause react
and react-native
I can import easily@titov https://facebook.github.io/react-native/docs/geolocation did u check this out?
Yes and I can't import it, here is my code: (def Geolocation (js/require "react-native-geolocation-service"))
As a browser polyfill, this API is available through the navigator.geolocation global - you do not need to import it.
Yeah, you right, so how can I access methods of this module? I've tried
(.-requestAuthorization (.-geolocation js/navigator))
for getting access but it's an object not a method 😕android:futuree-app.android.core=> (.-requestAuthorization (.-geolocation js/navigator))
#object[requestAuthorization]
android:futuree-app.android.core=> (.-geolocation js/navigator)
#js {:setRNConfiguration #object[setRNConfiguration], :requestAuthorization #object[requestAuthorization], :getCurrentPosition #object[getCurrentPosition], :watchPosition #object[watchPosition], :clearWatch #object[clearWatch], :stopObserving #object[stopObserving]}
have a look into those interop articles shared by @U0AU4CPTN
Sorry I still don't understand. I try to call navigation.geolocation.requestAuthorization()
but it's impossible, there is only object navigation.geolocation.requestAutorization
:
android:futuree-app.android.core=> (.requestAutorization (.-requestAuthorization (.-geolocation js/navigator)))
#object[TypeError TypeError: navigator.geolocation.requestAuthorization.requestAutorization is not a function. (In 'navigator.geolocation.requestAuthorization.requestAutorization()', 'navigator.geolocation.requestAuthorization.requestAutorization' is undefined)]
eval code
eval@[native code]
figwheel$client$utils$eval_helper
nil
android:futuree-app.android.core=> (.requestAuthorization (.-geolocation js/navigator))
#object[TypeError TypeError: RCTLocationObserver.requestAuthorization is not a function. (In 'RCTLocationObserver.requestAuthorization()', 'RCTLocationObserver.requestAuthorization' is undefined)]
requestAuthorization@http://localhost:8081/index.android.delta?platform=android&dev=true&minify=false:29973:47
u should really read articles people here are sending you. If something doesn't work it means u are doing something wrong. As i am getting strong vibes that u are beginner i will explain in detail how to call the fn.
Read articles again and bookmark them use them as reference whenever you are using anything JS in CLJS.
in order to get call that fn u need do the the following
(.requestAuthorization js/navigator.geolocation)
any global variable or object in JS world is accessed by using js
namespace
so here u are saying "give me navigator.geolocation
object from js
namespace and call requestAuthorization
function
You are right, I'm beginner, I set a goal and I want to understand how this technology works, I really try to do my best, I read article and man, you write me code which does not work. I assume that there is no such function like requestAuthorization
:
android:futuree-app.android.core=> (.requestAuthorization js/navigator.geolocation)
#object[TypeError TypeError: RCTLocationObserver.requestAuthorization is not a function]
java.net.MalformedURLException: unknown protocol: blob
at java.base/java.net.URL.<init>(URL.java:657)
at java.base/java.net.URL.<init>(URL.java:546)
at cljs.repl$mapped_frame.invokeStatic(repl.cljc:332)
...
I checked it after connecting to react native debugger and working with navigator.geolocation
object. Now I'm trying to just get current position with:
(.getCurrentPosition js/navigator.geolocation #(fn [pos] (.alert (.-Alert ReactNative) pos)))
I like your ambition.
good, this is good for getting the coordinates. Be sure to set optional settings as i had bug where cached values was taken after first position request.
That should've worked 'cause the logic is the same when u call other functions (in ur case getCurrentPosition
) If you inspect the object navigator.geolocation
- it contains object getCurrentPosition
The reason why requestAuthorization
doesn't work could be many things
1. you didn't add permission
2. there is a problem with RN and your desired device
I should've tested the code on my side before posting it. Apologies for that
btw guys https://facebook.github.io/react-native/blog/2019/07/03/version-60 has anyone tried upgrading?