Search code examples
iosiphoneswiftmacosmacos-sierra

Sending information from iOS to macOS


I'm working on an app for iOS and macOS and should be installed on both devices (iOS device and Mac computer) to work.

I want an option to send strings from the iOS device to the Mac (for example: if the user writes "Hello World!" and presses "transfer" button I want to get it instantly on the Mac app).

What is the best option to send strings from an iOS app to a macOS app (it should work even when the device isn't near the computer and even if it's not connected to the same WIFI network)?

Thank you!


Solution

  • You have two Options:

    1. Server on MacOS + Client on iOS + Port Forwarding (Router)
    2. Client on MacOS + Client on iOS + Server in the Internet

    You would usually go for the second option because the user doesn't need to configure Port Forwarding.

    The connection would be a HTTP(S) connection. On MacOS and iOS there are APIs available which support HTTP(S).

    (If you need a more specific answer you need to ask a more specific question)