Notify user when connection is lost - delphi

An app I made connects to a database to retrieve and send data. Now, if the user has no Internet, it is the intention that the user is warned and sent to the start page.
If there is a solution for this on the service, the components are:
DSServer
DSServerClass
DSTcpServerTransport
On the client-side, a connection is made with a TFDConnection.
I know there is a way to check the session if it is active or not, but I don't know how to put this in code.

With the demo of Dave Nottage, we managed to check if there is an internet connection.
Don't forget if you use it on android to add the .jar file in the library of the android
SDK.
Klik here for the demo of Dave

Related

Firebase insecurity/public endpoints with iOS app

I've frequently heard that the main issue we need Firebase security rules is because an application contains all the configurations needed to connect to the database and thus users could do something like db.delete('*'), read/write whatever they want, etc. etc.
I can see how this is possible on a web app, as you could check out the requests being sent over the network and thus get the endpoint needed to connect to the database, but, on an iOS app, how would this be possible?
For instance, say I created some chat app with Firebase and released it to the App Store. When a user downloads it, how would he/she gain access to my database through an API other than the buttons etc I provide with them with? Is there something equivalent to the "Network" section in google chrome that shows all outgoing requests, and, from, this they could send a malicious request to my database? Would this require installing 3rd party software onto their device to see all outgoing/incoming requests and they could get the required endpoint/database connection info from there?
Thanks.
When a user downloads it, how would he/she gain access to my database through an API other than the buttons etc I provide with them with?
It's not hard to reverse engineer the contents of the IPA file to get both the configuration you provided, and also see what the code is that queries the database. The IPA file can be obtained pretty easily - there is not much protecting that, given the user effectively has full control over the device (e.g. jailbreak). Given that information, it's possible to simply invoke the public Firestore REST API to not just duplicate all the operations in the app, and but invent operations of their own.

Host page locally on iOS

I didn't know it was possible on iOS but lately I went to Japan and one of the free wifi apps wanted to install profile into my iPhone. When I confirmed installation it simply opened Safari with 127.0.0.1. It loaded some page and downloaded profile from there. How do I host some page on iOS?
Creating web server is nothing hard. It is lot of coding of course, but the principle is pretty easy.
There is lot of 3rd party libraries on the github (GCDWebService) just try to search for "ios http server"
To create it manually you need few steps:
1) With the help of CFSocketCreate you open new socket with specific port (standard HTTP 80, or secured one 443 should be forbidden without root access rights) what going to listen on network interface on incomming requests.
2) You need to prepare some receiver what will be triggered as soon as some request income. You can use NSFileHandle class and register NSFileHandleConnectionAcceptedNotification in your notification center. And allow background mode with acceptConnectionInBackgroundAndNotify method. But I recommend to read the manual first
NSFileHandle Apple documentation
3) Process the incoming request. The selector what you register is called and in NSNotification.userInfo property is the incoming request, and you can generate some page here and open it in safari, or in your app or do whatever you want.
4) If you want received some POST data or streams, there is needs to register NSFileHandleDataAvailableNotification what trigger selector as soon as some data to read are available.

Uploading a file to the server once a user gains access to internet ios swift

I'm building an application who's logic depends on uploading a file to a server. I want to solve the issue in that if a user doesn't have internet connection at the time of file creation, the application will run some kind of background thread(or any other method) to constantly check if the user has gained internet connection, and once he does immediately upload the file. This is for swift ios development. Appreciate any help to be given.
How about an approach using Reachability.swift to determine if you have an internet connection and then adding an observer via NSNotificationCenter to upload your files. I believe the examples on the Reachability GitHub page might achieve what you need.

Listen to iCal event changes from server

I am building the server side for a calendar application. The client side is iOS only. The original plan was the app will know of iCal event changes then tell the server. But that might be a problem with reminders (via Parse Push). For example, if the event pushed forward the reminder should come earlier.
Is it possible from the server side to be notified on iCal events? For example, when users create/update/delete an iCal event I want to know from a server to grab this information. Is this possible? Or does everything need to be done via a native app thats running?
My server is currently on parse.com. But I could use a separate server say NodeJS if needed.
As iCal is user/device dependent, unless user has synced his calendar events with iCloud. And in second case where user has activated syncing of calendar events, it is completly insecure for end-user to share his icloud details to other server.
How about creating 1 API at backend, which will update/delete requests from Apps for the calendar events, and that will update Parse notification events in background process. For this you can also write customized Parse apis either in NodeJS or any other technology stack.
And in the apps, you can sync the events with iCal using Event Kit:
https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/EventKitProgGuide/ReadingAndWritingEvents.html#//apple_ref/doc/uid/TP40004775-SW1
first, you need to able to let iOS wake up your app running in the background, that requires to classify your app to one of the mode stated in the Apple Background Execution, I think the "Background fetch" is appropriate in your case, then in your application:performFetchWithCompletionHandler: you could check the Calendar database for changed events and preform necessary updates to the server.
I think this is your best bet:
https://stackoverflow.com/a/23997912/1967872
In your implementation of the storeChanged: method mentioned in that answer, you should iterate through all the events, detect any changes and submit those to the server.
I don't know exactly that is possible or not but I am thinking it's hard because still I didn't find any library/any features that apple is provides like that.
But I am putting one link that might be helpful for you. Please check it.
http://kb.kerio.com/product/kerio-connect/os-x/support-for-apple-ical-calendar-using-the-caldav-standard-1494.html

How to share links via FB App when I am offline

I am developing an mobile app for iPhone. The app will primary used by people who are on holiday in a different country and will be offline most of the time, due to high costs for internet traffic.
However, the company for which I am developing the app wants to users to be able to use the "Facebook Share" functionality also when people are not connected to the internet.
It should work on a way that they click the SHARE link button in the app, but then get a message that they are offline and the link will get shared as soon as they are online again.
I am trying to figure out how to do this. Can I pass the link I want to share to the official FB App via fb:// protocol (or whatever) and the FB App handles the post/share as soon as it is online again?
Or do I have to do it on my own, put the links I want to share in a internal database and then post them to the wall when I am online again?
Or any other ways??
Any suggestions would be welcome, I would prefer a very quick solution and hope someone maybe has an idea how to do this. I was hoping I can pass the share-link to the official FB App and this one handles everything when it goes online again !?
Thanks for your ideas!
Your approach should be to make your link-sharing code automatically cache requests until they are sent. The app then doesn't need to concern itself with the details - it can just post the link and get a 'failed', 'success', or 'postponed' response from your API and notify the user accordingly.
Your link-sharing code can then internally check if it can currently post to FB and if not (either because the user is currently offline or perhaps the Facebook token is expired) it will store it for later. This class will then re-check periodically (for example when the app comes to the foreground or when the class is initialised the next time the app starts) for connectivity and then it will check if the token is still valid and perform FB login if required. Once it has a valid token it can then iterate through the pending requests and act upon them.
If you really want to make it nice and clean, you can separate out the code that accepts incoming requests to do something, checks if it can be performed now, does it or stores it for later, and periodically checks any requests in the pending queue. This class will not have any idea what the requests do or how they are performed, it will work with another class that implements a protocol to do the actual work and knows about facebook, etc. There may even be an existing design pattern for such a setup, but I don't know what it's called if there is.
Update: I did some research and found this is very similar to the "Fire-and-Forget Pattern".

Resources