Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Allow editing of app from one iPad to another iPad
Started by bkove12 Feb 10 2020 08:51 AM

10 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

Hello All!

 

I am currently working on an app for a friend. He has a small restaurant business and I am making a seating/wait-list app for him. Currently the app allows the host to tap seats to show they are taken or free and add people to a wait-list. The wait-list data is using a mySQL db file and the table data is a JSON file. I have them saved just in case the app is closed by mistake. He wants the app to be on two iPads one upstairs and one downstairs. The one downstairs will be plugged into a tv that the guests will be able to see. I currently have it set up where the iPad downstairs mirrors the screen of the one upstairs. The one upstairs has the app running and being used by the host. My issue is he's now suggesting that instead of just having the host upstairs be able to edit it that the host downstairs can as well.

 

My Question: Is there a way (on iOS) to transmit the data from one iPad to another? 

 

I basically need them both to talk to one another consistently to know when the wait-list/ seating chart has been updated on either one. Once updated on one the data needs to transmit to the other and then be displayed on both. Is this possible? If so how would I go about doing this?

 

Thank you,

-B



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,176 posts
  • Corona SDK

Well, this is an interesting one. There are quite a few ways that you could approach this.

 

You could consider looking into something like this: https://coronalabs.com/blog/2014/09/23/tutorial-local-multiplayer-with-udptcp/


  • roaminggamer likes this

[TOPIC: post.html]
#3

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

Thank you for your reply. Do you know if there is anything a bit less complex? There's no way to access one iPad remotely with the other is there?



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,176 posts
  • Corona SDK

Well, no. You can't directly "edit" another app remotely like you might be thinking about.

 

The method that I linked isn't really all that complicated. It may seem a bit daunting, but the tutorial is quite comprehensive.

 

Since you are using MySQL, you probably have some PHP and MySQL integration going on as well, right? If you do, you could make a... well, a bit naive function that keeps checking the server for updates every X seconds, every time the app resumes, etc. Now this wouldn't be a scalable or even technically the best way to do this, but since your client would only have a limited number of devices connecting to the server, the server could easily manage being "bombarded" by a few devices every few seconds.

 

You'd keep a record of what information is stored on the server and what is stored on the devices, and you'd know that if the information on the server is different from what you have on the device, then one of the other devices has updated the information, so you'd download the information and update it on the device as well.

 

-

 

Alternatively, you could look at some other server setups and/or push notifications, i.e. if one devices pushes new information to the server, then the server pushes the same information to other devices as well. I believe that Firebase does this. This would be a scalable and a technically correct way to approach this, but I think it might be a lot harder than the other methods. 



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

I would suggest looking at the icloud plugin. It offers a key-value data store where you can have one iPad write information to the key-value store and any other iPads logged in to the same apple ID will be able to read the values back.

 

That would be the simplest approach.

 

Rob



[TOPIC: post.html]
#6

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

Hi Rob,

 

Thank you for the advice. With this plugin can I have the app write to a cloud document and load from that same document? So rather than having a .JSON and .DB in my DocumentsDirectory it would be in the icloud and would be reading and writing to that.

 

Thank you,

B



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

You could, but I think that you're over thinking it. iCloud can sync docs, have a full fledged database or have a simple data store like preferences that's shared.

 

App A: can write a JSON string to  string based key-value pair. App B can read the JSON string and Volia data shared.

 

See: http://docs.coronalabs.com/plugin/iCloud/set.html

and

http://docs.coronalabs.com/plugin/iCloud/get.html



[TOPIC: post.html]
#8

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

So currently I have a sqlite thats populated into a tableview when data is entered (like the business sample app). How would I go about uploading this data? Do I have to change how its set-up/saved and make it JSON? 

 

Thanks!

 

-Sorry if I'm not getting it. I'm not great when it comes to database stuff and having to sync between two devices gets my wires crossed. 



[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

I can't really give you a copy and paste code because I have no idea how your data is organized or what your tables are called. But lets assume you have a table called openTables that has your list of tables and if they are occupied and is inService or not and whatever data you are tracking. It really doesn't matter since we are going to be using the top level data and converting it to JSON and back.

 

When your data updates:

local json = require( "json" )
iCloud.set( "data", json.encode( openTables ) )

Then to make sure the iPads stay up to date:

timer.performWithDelay(10000, function() 
     local openTables = json.decode( iCloud.get( "data" ) )
end

You may have to program a defense against a race condition where the timer could in theory update your local table while you're in the process of attempting to write the data. Maybe pause the timer while you're in the middle of the update sequence.

 

Rob



[TOPIC: post.html]
#10

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

Okay I'm going to try this and get back to you. I'm assuming I'm adding the iCloud.set function to run any time the table change function occurs and any time a new waitlisted person is added.

[TOPIC: post.html]
#11

bkove12

[GLOBAL: userInfoPane.html]
bkove12
  • Enthusiast

  • 92 posts
  • Corona SDK

I'm probably doing something wrong. I'm not sure if it's the code or how I'm setting it up in my apple developer profile. Is there any snippet of code that you would suggest I provide you to help you see what I may be doing wrong? I can also put my project up on git if that helps.

 

Thank you!




[topic_controls]
[/topic_controls]