4

Background:

I am just about to start development on an mobile and desktop app. They will both be connected to a local wifi network (no internet connection) and will need to communicate with one another. At the outset we are targeting iOS and Windows as the two platforms, with the intention of adding Linux, OSX, and Android support in that order. The desktop app will largely be a database server/notification center for receiving updates from the iOS apps and sending out the data to other iOS apps. There may be a front end to the desktop app, but we could also incorporate it into the iOS app if needed.

For the moment we just want the iOS app to automatically detect when it is on the same network as the server and then display the data that is sent by that server (bonjour like).

As far as I see it there are two paths we could take to implement this

  1. Create a completely native app for each platform (Windows, Linux, OSX). Pro: We like the ideas of having native apps for performance and ease of install. Con: I know absolutely nothing about Windows or Linux development.

  2. Create an app that is built using web technologies (probably python) and create an easy to use installer that will create a local server out of the desktop machine which the mobile apps can communicate with. Pro: Most of the development would be cross-platform and the installer should be easy enough to port. Con: If we do want to add a front-end to the server app it will not be platform native and would be using a css+html+javascript GUI.

Question:

My question is how would implement the connection between the iOS app and server app in each circumstance.

  1. How would I receive and send notifications over a local network.

  2. How could I connect to the server using NSURLConnection if it does not have a static ip?


I hope this is clear. If not please ask and I will clarify.

Update 09/06/2013

Hopefully this will clear things up. I need to have a desktop app that will manage a database, this app will connect to iOS devices on a local wireless network that is not connected to the internet. I can do this with either the http protocol (preferably with a flask app) or by using a direct socket connection between the apps and the server. My question is which of the above two choices is best? My preference would be for a web-based app using Python+Flask, but I would have no idea how to connect the iOS app to a flask app running on a local network with out a static ip. Any advice on this would be appreciated.

xizor
  • 1,554
  • 2
  • 16
  • 35
  • Well I guess you can try to connect from say, 192.168.1.* to 192.168.1.*, make a simple response on the web server, and when the iOS client attempts to connect, the server sends a welcome response. – William Yang Aug 23 '13 at 22:53
  • With desktop windows machines you can use domains, for example `http://my-server/my_web_app`, but of course, iOS cannot connect to windows domains. Not without some crazy techniques. Therefore windows domains = not usable. – William Yang Aug 23 '13 at 22:54
  • There may be a wording issue. Are you really talking about system notifications in the APNS sense of it ? If yes, I really doubt Apple will let you by-pass its servers (supposing that's even remotely possible) – Alex Sep 06 '13 at 07:54
  • @Alex I have just tried to clarify the question with an update. – xizor Sep 06 '13 at 20:39
  • Notification wise, that's not any clearer, at all. What do you exactly imply by notifications, infrastructure wise ? In iOS you can't run an app as a service. You can attach it to an existing one - APNS for that matter - . So, please, be more specific on the notifications part, because I still don't get what you are trying to implement. – Alex Sep 07 '13 at 05:39
  • @Alex, by notifications I just mean that when one iOS device updates data in the server component - then that server component must send a message to the other iOS devices letting them know they need to refresh their data. I do not mean APNS. – xizor Sep 07 '13 at 13:31
  • 1
    Ok, got it. So, unless your app is already running in the foreground, I think it's impossible. There's only one notification mechanism on iOS, you can't create yours so that it wakes up, starts your app, or sends background notifications. You can keep your app running in the background, but there's a 5 min limit. Not very useful for your problem. May be you can use a corporate proxy to allow apns to go through, while blocking all other Internet connections? – Alex Sep 07 '13 at 15:50

2 Answers2

1

Without any details of the application or frameworks its hard to be more than vague and point you in the right direction. If you have already explored Bonjour/Zeroconf to connect the iPhone to the server, I'd keep looking down that path.

The first place to look is PyBonjour for how to broadcast the server from Python. Although there are a few issues in how to configure this on Windows vs. Mac vs. Linux, this will be slight. For example, for windows the user will need to install Bonjour for Windows, where as Linux users will need Avahi, but most of this can be setup durin install.

Secondly, look at the Bonjour documentation for iOS, which will be much easier as its all built into the system and APIs. From here both server and client are discoverable to each other.

The last issue is determining if you want the iPhone to connect to the server or vice versa, and how. These however are basic networking decisions that more or less subjective.

Since you've indicated a preference for web development, you could easily have the iPhone connect to the Flask server and retrieve details from the server using HTTP/HTML technologies.

With regards to notifications, unless a change in data by client A means that client B absolutely needs to know about the change in data, I would not worry. The next time client B connects to the server, the correct data can be push through at that point rather than worrying with notification services. If another client does need to know about a change, another solution may just be regular old email that advices them, and prompts them to open the app.

0

I would definitely suggest a webapp. And the answer to your questions are given below:

How would I receive and send notifications over a local network.

Use a REST based web service to communicate with the server. You have to use polling to receive data:-(

How could I connect to the server using NSURLConnection if it does not have a static ip?

  1. If possible configure a domain name in your network which points to server ip. (Configure local DHCP to give same IP to your server every time based on mac address!)
  2. Have a IP Range and when the app starts, try to reach a specific URL and check if it is responding.
  3. Ask the user to enter the server IP every time the app starts!
Vinod Kumar Y S
  • 628
  • 3
  • 9