capacitor app log local ip address in offline request - capacitor

I would like to log the ip address in some requests. For this i would like to get the info from the network-interface in my app. As it is a offline app that replicates to couchdb and not server requests this is proving to be difficult.
i was thinking of using #capacitor/network but this plugin only tells me if there is a network connection and no infos.
Then i tried cordova-plugin-networkinterface but i could not get this plugin to work properly because it does not show in cordova.plugins like cordova-plugin-badge.It does show up in the window object as window.networkinterface.getIPAddress() but it returns "undefined".
Can someone please tell me why cordova-plugin-networkinterface does not work in capacitor (not using ionic) or a different approach.

Related

Database info not showing when previewing site on mobile?

I have made a simple full stack application that uses a postgreSQL database. When previewing the site on desktop it works fine and is able to retrieve all the information with no problem so long as my backend server is on. I am trying to preview the site on my phone using my IP address followed by the port number and it comes up just fine but only the frontend is displaying on my phone. I am unable to see any information from my backend or database. Does anyone know why that is or how I can fix that to display on my phone (without hosting the site)?
1.Maybe it's just cashing issue.
check your mobile phone browser cash setting.
In general, browsers use caching technology for performance reasons. Caching refers to storing values that you previously requested locally and then reusing old values without using new values when a similar request comes in.
2.Maybe it's a front-end css problem.
If design-related elements such as css are not accurate, problems that cannot be seen on the screen may occur even if server data is imported normally.
3.Or maybe front-end can't get data from the server at all.
In this case, it is necessary to debug the server source, check whether it is sent normally on the screen, and check whether the response is received normally through the network terminal.
After checking the three above, even if you can't solve the problem,
At least you'll know exactly what the problem is.

How to use Google Action Builder with my own server

I want to develop an action to google assistant. So i red the documentation here https://developers.google.com/assistant/conversational/overview and i followed this tutorial https://www.youtube.com/watch?v=Z1hxvniJ18s
It s worked and i was allow to develop and test my app in the simulator. The problem is that when it's come to webhook i don't totaly understand how it's work. On the webhook icon i got this
The seconde one allow me to use Google cloud function and firebase but i had to add my billing account to make it available. I also get a console where i can code my fonctions and my responses.
And if i am correct, the first one allow me to connect to my own Api. But i can only enter one field that is the URL adresse and nothing else so how do i code it? Also i see everywhere people using node.js and i would like to use php is it possible?
To sum up my problem, i would like to know how i could connect my action builder to an other service(Api) than google ones? If it's possible to run my server in php and how do i interact with my google action?(I think it's by sending json back and forth but i'am not sure how to do it?) Finally i would like to know if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
I would be very grateful if someone could help me, show me how to set up all this.
But i can only enter one field that is the URL adresse and nothing else so how do i code it?
When you develop your webhook, you will need to have a single publicly accessible endpoint to connect with. This endpoint will receive an HTTP POST request and you will need to respond with an appropriate response.
Also i see everywhere people using node.js and i would like to use php is it possible?
Any language that can run on a web server can work. Node.js is one that is used a lot, but PHP can work just as well. You can create an actions.php file and then enter an endpoint address https://example.com/actions.php that will be called. You may need to refer to the Request and Response reference for the expected format.
if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
It's somewhat possible. You'll need to have some method of sending mock requests to your local server, which might be as easy as using cURL or other tools like Postman.
Unfortunately my personal experience with PHP tools is limited, so I can't necessarily walk-through the specifics. But it does seem like you know these tools a bit more and should be familiar enough to be able to get started.

Simple Localhost Server in Xcode/Swift?

I am making a macos app in XCode, and I was wondering if there was a way to make it host a local server that is visible across the network.
I am trying to find a way so that it would host something on the devices's network with it's hostname/ip address, so if someone goes to http://hostname:5000 they would be able to see the response, and the app would be able to see the request, just like how hosting a local python server works. Is there any way to do this in XCode with Swift?
For example: the user presses 'start server' on their screen. The server is hosted across the network. Anytime a request is made to it, they get a notification.
Just to make you concern you may find some sample codes, including local web server inside the app.Few of them I found are:
https://github.com/ooper-shlab/MyWebViewApp-Swift
https://github.com/depoon/SwiftLocalhost
The main thing is it's just a public
, experimental code, so it's not simple, not easy to adopt, not all coding best-recommended, far from readable and may have severe bugs.But you can use it as a working example and take any parts of it into your app.

How to develop google actions locally?

My question might sound basic or lame to you but I really have zero experience with this. I am so new to Google Actions and I don't have that much idea with Javascript. My question is how do I develop a Google Action without using the online editor google provided? Can you please narrate it to me step by step? I tried enrolling myself in codelab exercises that I hope might help me but in the codelab exercise, there was already a bunch of codes I cloned from github and that was what I used to make it all work. But now that I want to code for our real project, I don't know how to start from scratch. I know how to create an agent and stuff.. but I don't know how to develop locally. PLEASE HELP ME. THIS IS FOR OUR THESIS.
If you have followed the Build Actions for the Google Assistant (Level 2) codelab, you'll see that it talks about setting up for local development in step 3 using Firebase Cloud Functions. If you scroll down to part 4 on that page, what follows replaces some things in part 4.
Instead of typing firebase deploy as it suggests, instead type
firebase serve --only functions
What this does is, instead of sending the code to the server, you run the code locally in an environment that emulates the Firebase Cloud Function configuration. It will show the full path that is available on localhost. If your function is named something like "webhook", it will show something like:
functions: webhook: http://localhost:5000/your-project/us-central1/webhook
This now lets you use the ngrok command in another window with something like
ngrok http 5000
and that window will show the URL and hostname that are the external point. So it might be something like:
forwarding https://8ba32042.ngrok.io -> localhost:5000
You would combine these two to make the URL that you should use as the fulfillment webhook URL. Using our example, it would be something like
https://8ba32042.ngrok.io/your-project/us-central1/webhook
that you would put into the Dialogflow fulfillment URL setting.
You can then stop and start the local firebase hosting as you change things in your code and examine the request and response using the ngrok console. If you ever stop the ngrok command line, when you start it again you'll get a new hostname, and you'll need to change this in Dialogflow as well.
Download NGROK
Download NODEJS
Develop a local webhook using Express on NodeJS
Expose this local webhook to the internet using NGROK
Use the NGROK generated URL as the fulfilment to your Dialogflow agent.
Integrate Google Assistant with Dialogflow and test it.
Here is a tutorial to start with

iPhone data export

I'm writing a data collection app for the iPhone, and want to be able to export my data to a file the user can process on their desktop. I'd generate the file in csv or whatever format on the iPhone and then somehow the user would get the file to their desktop. From reading other questions here and on the rest of the web, it seems like my options are:
1) Implement my own web service somewhere in the cloud which the iPhone app connects to and sends the data. Then my server would either email it to the user or make it available for download somehow.
2) Write SMTP code or use an off the shelf library, which would require the user to enter their own email server details. Then send the data to the user as an attachment.
3) Use some kind of bonjour setup where I give the user an app to run on their desktop and the iPhone app finds and talks to that desktop app.
All three of these seem cumbersome: #1 for me because I have to code/maintain a server (including detecting/preventing spam/misuse, etc). #2 and #3 for the user because there's extra configuration, stuff to run, and things that can go wrong. (Not to mention a bunch more things to code and test for me, potentially with a bunch of desktop OSes and configurations.)
Are these the options people are using? Did I miss any? Which do people like best?
Thanks much!
You can run a web server on the phone, and point the user at that IP address, then serve up an AJAXy web page where they can download the file to their desktop.
Not hard, but they have to type in an IP address or http://myphone.local type address...