How to config Server Side in order to catch the positions that its being sent by the plugin #125
Replies: 7 comments 4 replies
-
I don't have any experience with this backend server unfortunately... |
Beta Was this translation helpful? Give feedback.
-
You are saying i will be the first ti taste this part of the plugin?? But in the example there is a local IP (url: 'http://192.168.81.15:3000/location',). In the documentation there is an item "HTTP Location Posting". Then? |
Beta Was this translation helpful? Give feedback.
-
it is the same as anyone else. Ive never works with java and this kind of connections im not familiar. |
Beta Was this translation helpful? Give feedback.
-
Ok, but do not work like JS. There is something else in the middle that im not doing well and im asking you to help me, this is my first time working with cordova from inside. The messages logger by Android: W/.expressremise: Got a deoptimization request on un-deoptimizable method java.net.InetAddress[] libcore.io.Linux.android_getaddrinfo(java.lang.String, android.system.StructAddrinfo, int) This is with HTTPS protocol. The next its with the HTTP protocol. D/com.marianhello.bgloc.PostLocationTask: Executing PostLocationTask#postLocation If i can make this work, i can go forward with my project. Im asking you to help me, because ill never work with JAVA httpclient and ive not have a clou how... I will try to do my best from my side but i appreciate any help from you. Thanks |
Beta Was this translation helpful? Give feedback.
-
Well, y did it!!! There is a very important question to consider, whether the connection is secure or not ( HTTP or HTTPS ). Because if the connection is secure, you have to make 'ADJUSTMENTS' with the issue of CERTIFICATES, the function after this paragraph solve any problem.
As you can see, the function returns a SECURE CONTEXT ( SSLContext ). The next thing to do is bind it to the connection that we are going to make. Something like this. SSLContext sslContext = getTrustContext(); HttpsURLConnection url = new URL("https://www.example.com").openConnection() url.setSSLSocketFactory(sslContext.getSocketFactory()); Later I found that the code that sends the connection data did not do so, so I changed it to the following. url.setRequestProperty("Content-Type", "application/json; charset=utf-8"); DataOutputStream wr = new DataOutputStream(url.getOutputStream()); // data it is the String parameter to send wr.write(data.getBytes(StandardCharsets.UTF_8)); int status = url.getResponseCode(); //System.out.println(status); BufferedReader reader = null; if (status > 299) { while ((line = reader.readLine()) != null) { reader.close(); if (status > 299) { I think with this code someone can do the code for the other protocol ( HTTP ). This is the best of me to help to this FANTASTIC project. Thanks!!! |
Beta Was this translation helpful? Give feedback.
-
I´m working on Codeigniter 3, but I don't know how the data arrives, anyone knows, I send it this way. url: "BASE_URL/api", |
Beta Was this translation helpful? Give feedback.
-
You have to put an ENDPOINT in the property *url*, something like this:
https://yourdomain.com/index.php?c=yourcontroller&m=yourmethod
Then in your method in the variable $_POST['rawdata'] you are going to have
the LOCATION GMS data.
if (isset($_POST['rawdata']) == false AND $raw = '') {
$httpContent = fopen('php://input', 'r');
while ($kb = fread($httpContent, 1024)) {
$raw .= $kb;
}
fclose($httpContent);
$raw = json_decode($raw) -> rawdata;
}
I hope this helps. Fabián.
El vie, 1 sept 2023 a la(s) 18:28, jrubiano01 ***@***.***)
escribió:
… I´m working on Codeigniter 3, but I don't know how the data arrives,
anyone knows, I send it this way.
url: "BASE_URL/api",
httpHeaders: {
'Content-Type': 'application/json'
},
postTemplate: {
id: 1,
state: 1,
latitude: ***@***.*** <https://github.com/latitude>',
longitude: ***@***.*** <https://github.com/longitude>'
}
—
Reply to this email directly, view it on GitHub
<#125 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGQTCXZFPHABEQIUU25H4TXYJHQNANCNFSM6AAAAAARBHQ6HM>
.
You are receiving this because you authored the thread.Message ID:
<HaylLtd/cordova-background-geolocation-plugin/repo-discussions/125/comments/6889704
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
The plugin sends a POST to the URL configured. My servier is an Apache with PHP installed and the request never past the first instance that its "W/.expressremise: Got a deoptimization request on un-deoptimizable method void com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(long, com.google.android.gms.org.conscrypt.NativeSsl, java.io.FileDescriptor, com.google.android.gms.org.conscrypt.NativeCrypto$SSLHandshakeCallbacks, int)".
Can you help me to do this. Because with JavaScript i dont have any problem to POST anything.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions