iOS communicating with OS X - iphone

I'm looking for a pointer in the right direction to get started with writing an iPhone app that sends commands to OS X, for example telling OS X to sleep. I can't seem to find the relevant part of the documentation?

AFAIK, most apps have been performing this kind of communication with a client/server design, where a "server" app runs on the host OS X machine, and a "client" app on the iOS device connecting using some sort of protocol (HTTP? Bonjour?).
You won't find this in the documentation because this is a niche design pattern that few apps need (especially since documents can now be shared more easily with the new version of iOS and iTunes).

iOS doesn't support ObjC remote objects, which would be the easiest way to communicate between two OS X machines.
An alternative to the HTTP client/server approach could be making your iPhone app connect in via a remote Unix shell to the OS X machine (via ssh) and then issuing Unix or AppleScript commands to perform your system actions.

You could also set up a socket connection. I have done a app for Android, that does exactly the same for Windows computers. The app is in use in a computer store :)
For Mac, you have to use sudo command, so you need the user to type in password, on first use.
Then the server application on the Mac can send "sudo shutdown -h now" to the terminal when the server application gets a predefined byte stream on the socket input.

Related

How to send parameters to daemon from client to server?

I am trying to create a kiosk client that stores its configuration on the server. Client is based on Raspberry Pi OS Lite (it runs on RevPi). Server is an Debian system. What I had in mind is following process:
boot kiosk (first boot with customized Raspberry Pi OS Lite)
kiosk will ask for server IP (maunual input)
kiosk will create ssh key at this moment
kiosk will ask server at given IP for registration (passing its MAC and generated key?)
? Server will receive request from kiosk with MAC and generated key.
server will create config file for that MAC address (copy from template) and do some more adminitrative tasks.
kiosk will reboot
after boot kiosk will check if his local config file is same as version on the server
if not: kiosk will download it AND reboot.
if yes: it will precess it and run... for ever till end of electricity.
I am done with cleaning up kiosk, I have installed what I need, all is configured as I wanted.
Now I am looking for an elegant solution to my only problem, atm:
How to send kiosks MAC address to server without any login ceremony. I thought of using a daemon on server side that listens at port for and messages with MAC address and ssh-keys but it have no idea how to
I used info from how to pass arguments to Linux daemon/service and my daemon is based on http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html
Ok, after looking around I found spring-server. This is much more then I anticipated for! But all additional functionality offers more application possibilities! Thank You Bartobri.
With implementation of this answer I am good to go.

Bluetooth custom Pairing using a windows service

We're working on an .net core 3.0 app under UWP win 10. The app runs as a BLE central, connecting to BLE peripherals. We use the Windows.Devices.Bluetooth namespace which defines a Windows Runtime API that allows UWP desktop apps to interact with Bluetooth devices.
When we run the app as is, we can pair without issues. However when we wrap the model within a windows service, everything works but the pairing process which returns a Failed DevicePairingResultStatus for the pairAsync(pin_number) request. The code which is run remains exactly the same in both cases.
Pairing is performed with DeviceInformation.Pairing.Custom.PairAsync(DevicePairingKinds.ProvidePin, DevicePairingProtectionLevel.Encryption) method.
We've tried running the service as logged on as Local System, Local Service, local user with admin privileges, Administrator and Network Service with the same results.
Windows 10 is updated as well as Bluetooth drivers, Bios etc.
Does anyone have any suggestions as to why the difference exists between running as a windows service and running as an app? And how to bypass this?
Thanks!

objective-c : iphone programming wirelessly lock computer from iphone

i am doing an application in which i need to lock,turn off the computer wirelessly.
It is possible?
Yes, but you'll have to write two programs:
The iPhone app that sends the lock command to the computer (over the network)
A program running on the computer that listens on the network for commands and locks the computer when it gets them
It's possible. For example, you could run a daemon on your computer that listens for a command to lock or shutdown, and your iPhone app can connect to the computer and issue the appropriate command. Of course, you have some considerations such as firewalls, NAT, and security issues to deal with.
To bypass some of the problems Jeff mentioned, you need to build a service that brokers communication between the iPhone app and the machine.
The program running on the machine needs to talk to this service over HTTP/S (so no NAT/Firewall problems), and keep polling (see long-polling). The iPhone app sends the server information when it wants to shut down the computer. The server sends an appropriate response in such a case to the long-poll, at which time the client software on the computer turns it off.
So yes, to do this right you need a stateful server.
Good luck.
Airlock does something similar for the iPhone/Mac via a System Preferences plugin and bluetooth (but no app on the actual phone).

Monitor iphone application api calls

I was wondering if there is any way to monitor 3rd party iphone applications' api calls? For instance if application access address book is there a way to monitor that or intercept call? I understand it may not be possible to do so without jail-breaking, but is even possibility after having jail broken the phone?
Thanks!
Yes..
Download the mitmproxy tool and set it up by going to the folder of
mitmproxy and running sudo python setup.py install. If all goes well,
mitmproxy must be available in your $PATH.
Start mitmproxy by running
mitmproxy.
Obtain the IP address of your computer by running ifconfig
en1 (or whatever is the interface that you are using).
Set the proxy
on your iPhone by going to your wireless settings, setting the proxy
to be “Manual”, and set the IP to be your computer’s IP and the port
as 8080.
Source and awesome use case...
http://mclov.in/2012/02/08/path-uploads-your-entire-address-book-to-their-servers.html
No there isn't.
You can howerver, starting in iOS4, see what apps have used location services (you can find this in settings.app).
If you jailbreak the phone, you can replace the frameworks and add any required logging. It's going to be pretty difficult to do, though.

iPhone - access XAMPP server (localhost) on my mac in the same network

I want to create an iPhone app which makes calls to a web service. For testing, I want to first create the API calls on my mac (server running XAMPP) and if it works fine there I want to port it to the actual server.
If my iPhone and mac are on the same network, can I access the web service using the IP address of my mac?
Thanks.
Any time someone answers with "why not," ignore the post. This just takes up space and adds absolutely no value...their post imitating their life.
Anyway, I access my laptop localhost (WAMP stack) from my iPod Touch by entering the IP address of my laptop on my Touch location bar. There is some configuration that needs to happen for this to work. I found what I needed at:
http://www.frihost.com/forums/vt-88381.html
Good Luck!
I can not speak about actual development, however I access intranet pages from a Ipod Touch all the time by either typing http ://ip or http://local_dns_name
As long as the iphone / ipod is on the network correctly (e.g. through standard wifi and not 3g/whatever) you should be able to access any and all local resources.
What I do:
Connected to the same network, I go in to the wireless settings and create a manual proxy that points to my machine. I use Charles proxy for testing a lot/seeing traffic, works like a charm and it lets me use my macbook hosts file so I don't need to do any funky listening rules in apache - just the same vhost settings I use on my machine already.
http://www.charlesproxy.com/documentation/faqs/using-charles-from-an-iphone/
Why not?
Have you tried it and have some problems?