communication between 2 instances of the same app on 2 devices for 1 user

My app will probably never be on the App Store but I used it as a way to learn

For now it is just for me but I hope to one day to put it open source.


I have made an app that monitor my solar ebike, for many parameter and some calculated. I use it while a ride but also when the bike is parked and is charging. The bike is parked far from my appartement but I have an iPhone connected to it all the time.


I would like to have an app on my iPhone to send a message to the iPhone on the bike to ask to send me the current data.


I understand that it would not be a good thing to do because it would mean that app developper could change thing in the app remotely.


So I though, What if this could only work between two devices with the same AppleID.


I have absolutely no idea how to do that

preferably in a way that is AppStore compliant and privacy correct.


i could just send the data every 20 minutes, but i want to learn and also i would like to have more flexibility, for example, one day I would like to send a command to open the switch to the battery to stop the charging.


If you have suggestion on how to proceed I would be very happy. :-)

Replies

Sounds like a job for notifications. Not sure if either app in your example needs to be kept in the foreground, tho, but you'll figure it out.


If that doesn't serve your specific data requirements, try CloudKit API, which allows developers to sync data between devices.


About remote control over the charger, that is doable, I believe, depending on your hardware, but non-trivial, I think. You'd need to explore bluetooth & wi-fi devices (might involve MFi) you can hook into first, then add the required support to your app.

What if this could only work between two devices with the same Apple ID.

I like CloudKit for this. It automatically takes care of the “same Apple ID” requirement, and you can set it up to generate silent notifications for you, avoiding the need for you to deploy your own push provider.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"