Turn iPhone into a server programmatically? - objective-c

I want to make my iPhone app display on a Mac's screen, kind of like AirPlay does with other machines. The only way I have heard to do this is, although I do not like it, turn the iPhone into a server. Unfortunately, I cannot figure out how to do so. I also wanted to set it up in such a way that my Mac automatically detects it. I have seen a similar setup in the game Chopper 2. My Mac app will have a simple timer that fires every few seconds to look for the iPhone, in the same way that Chopper 2's "Find iPhone" button does.
Is there a simple way to turn the iPhone into a server, or start a "session" like Game Center does?
One last thing: I know it is somehow possible, because another app I have actually gives my iPhone a web address at the click of a button. It is called the Dicenomicon, if you want proof.

First there is no easy way to redirect your display to Mac, even if you made it a server of some kind.
Second, to discover or publish customized services on WLAN, you may want to refer to the samples on Bonjour:
CocoaHTTPServer: a simple TCP/HTTP server.
WiTap: an app that discovers and connects to services of the same kind on WLAN by Bonjour.

I'm not really sure what you mean by "server", because there is no way to share the screen of an iPhone using the official SDK, although this is possible by jailbreaking.
It would be possible, however, to send data back and forth between the Mac and iPhone, and display the data on the iPhone, on a Mac. Using that data, you could try to recreate the interface on the Mac. All of this could be accomplished using sockets. A class that might help with that would be cocoaAsyncSocket, which makes network programming a lot easier.
The auto-discovery of iPhones on the local network is achievable with Bonjour. Without getting into too many details, NSNetService would allow you to publish a service for your app from an iPhone, and NSNetServiceBrowser would allow you to find that service on the local network from the Mac. From the NSNetServiceBrowser, you could establish a socket connection with the iPhone.
Good luck!

You might want to take a look at the GameKit APIs, I know they do something similar between two iOS devices.
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/Introduction/Introduction.html

Related

How to create background location service in Appcelerator Titanium working after restarting device

I want to make an application which will send information to a server about user's location every 30min. It is needed to provide location specific push notifications.
I need such functionality for Android/iOS, which would work in background (also if device is restarted). I found some articles covering background services and I created background service doing that, but after phone is restarted it won't work.
Is it possible with Android and iOS? How can I achieve that?
With iOS, no. With Android, yes.
Apple has gone to great lengths to limit what apps can do. You can do some things in the background for an extended period of time (GPS, play audio, Voip, etc), but after a reboot your app will not be restarted until the user opens it again. There are exceptions to this. Voip apps are allowed to restart after a reboot, but apple will not approve your app for the App Store unless you actually have a place for a user in your app to use the Voip feature. Geofences are a possibility, but I haven't had experience with that feature yet. In my experience, Apple does whatever they can to make sure your app doesn't run forever.
With android, there is more flexibility and what you propose is totally possible. I've listed some important links below, since most of those solutions are far better documented than what I can do here.
Essentially you need to register as a boot receiver and then send an intent to start a titanium android service when the boot event is received. I don't have experience with starting a titanium service, but I'm sure its a simple intent you need to fire. Either way you'll need a module for this native code. I attached a link to a bencoding titanium module that may help you, although there may be some others out there. You may even need to code one yourself.
Samsung is notorious for stopping your app with their SPCM feature. You may want to familiarize yourself with it. I've added a stackoverflow discussion link below.
I don't know all of your system requirements but honestly, for any app I would try my best to not run forever. It will hurt the battery life for your users and will add a lot of complexity. Maybe you could simply have the app check the GPS coordinates when it receives a push notification and decide right there and then whether to present a notification to the user? Just something to consider.
Either way good luck!
How to start an Application on startup?
http://docs.appcelerator.com/platform/latest/#!/guide/Android_Services
https://github.com/benbahrenburg/benCoding.Android.Tools
Dealing with Samsung SPCM killer

Controlling Network Settings in IOS 5

I have a project where it's highly desired to have some control over network settings in IOS 5 for an iPad device. The ideal scenario would be to have to ability to change the device's wifi connection to a specific SSID. My gut tells me that this is probably functionality that isn't exposed in the SDK but I figured I'd ask.
An alternate goal, if my first assumption about directly changing a connection is correct, would be to allow the app to prompt the user to change network settings and direct the user to the settings screen. I've seen a handful of apps offer this when, for example, the device is in airplane mode and the app requires an internet connection. The major difference in my case is that I'm not necessarily looking to prompt the user just when the device is not on the internet but when whatever connection the device already may (or may not) have isn't the one I'm looking for (in this case, I'm looking for a closed/non-internet-facing Wifi ssid on an aircraft).
I appreciate any pointers that can lead me in the right direction.
It might not fit perfectly what you want but I think CaptiveNetwork is the closest you can get.
The API bindings for CaptiveNetwork are available in recent MonoTouch releases.

Robust real-time communication between iOS App and Mac App

We're working on an exhibit (http://pulse.media.mit.edu) and I'm brand new to iOS, objective-c and Xcode. The exhibit deadline is in one week and I'm stuck.
The problem I'm having seemed simple enough.
Our exhibit has a projector and an iPad. The projector will be hooked up to a mac and be playing a video. The iPad will act as a controller for those videos. More simply:
I have 50 videos on a Mac. I need to develop an application on the Mac, that, when opened will loop one of the videos.
On an iPad, I need to develop an app that can change between the videos on the mac in real time. The iOS app is already designed, we're just struggling with some code.
On the mac, when the iPad tells the Mac to change video, we'd like it to switch between videos using Core Animation, like this (http://youtu.be/pyd8O-2mkgk?t=1m).
So my question: What is the most robust way to do this? It has to be able to run in a museum, for two months. Some things to consider:
We are 4,000 miles away and can't monitor it all the time. We'll
check nightly to see if it's still working, but it should run the day
without breaking.
If people unplug the iPad, it should still work.
It should be as robust as possible.
How can I best do this? Should I write to a database from the iPad onto a database running locally on the connected Mac and then monitor that database 10 times every second? Are sockets robust enough to use alone?
If you do suggest a way, can you please point me in the direction of some resources (frameworks, function names, etc) that can help me do this quickly?
Thank you for your time.
I would go for the server-in-the-middle option, because it will be easiest to debug, and requires nothing more than a working internet (wifi) connection on the client side. When having connection issues, all you need is someone who knows how to hook up an iPad or Mac to the internet. And you can see server-side which device has issues connecting.
Furthermore, using plain HTTP sounds like the best way to go for communication, and the backend can be written in any server side scripting language. Both clients should be polling the server every X seconds.
If you get this basic setup working well before your deadline, you could try to get the devices to connect to eachother directly (for a less sluggish user experience), and leave the server solution in there as a fallback method. The Mac app could function as a HTTP server, accepting the very same commands that the iPad normally sends to your server. The challenge will be to reliably know which IP to connect to. You could hardcode it or use Bonjour.

Transferring images from one iPad to another

I have an app which displays an image when I say some word, and the word is from my dictionary which I had exclusively created for the app.
Now I want that image displayed on my friends iPad simultaneously, when it shows on my iPad. Is there any way for that?
Thanks and regards,
Christy
If both iPads are in the same local network, you can use cocoahttpserver to run a HTTP-Server on every device and announce the services via Bonjour. Once a new picture is available, that devices connects the server on the other devices and informs it, that new data is available. The second device than will connect the server running on the first device and download the picture.
the advantage of this approach: the protocols you are using are well-know and a lot of additionally tools are available.
But you can also have a similar, more downlevel appoach, where you design your own network protocol. In that case I'd use Asyncsocket
Use synchronize image with both ipad using internet or use APN to notify that image is ready.

Location-based features in iOS

Not sure if this is possible, but I wanted to check it out.
I want to access the GPS features in iOS, specifically on iPad through my app. Ultimately the goal is to be able to see who else nearby is currently running the app as well. Is this at all possible or practical to implement?
Entirely. Check out the documentation on Core Location. Typically the way an app like yours works is that any devices running the app submit their location to a script on your server, then query that script for any other devices nearby.