0

I have two apps - rider and driver. If the driver accepts a request from the rider, the variable acceptedRyde changes from false to true - this needs to be passed to the rider app to trigger an alert to the rider that the ride has been accepted. The same is needed from the rider to the driver, if the rider cancels the request, a variable requestCancelled will change from false to true and needs to be passed to the driver app to trigger an alert.

Researching lead me to a post at Communicating and persisting data between apps with App Groups - but there are things I don't understand about it.

First off- to store data and receive data snippets - where do they go? if I am passing data from each other and reverse, don't know where to put it.

How do I pass it?

I am also using Firebase.

halfer
  • 19,824
  • 17
  • 99
  • 186
LizG
  • 2,246
  • 1
  • 23
  • 38
  • AppGroups is for communication between multiple apps in your post it looks like you have a single app. – LoVo Jan 19 '17 at 19:14
  • @LoVo No, I have two apps - 1.Rider and 2. Driver - I will edit my post, my apologies. – LizG Jan 19 '17 at 19:15
  • It depends on the type of data you have to pass. If it's simple data that can be stored in NSUserDefaults (key / value pairs), I would use a shared NSUserDefault to write / read the data between apps. It's not "passing" the data so much as it is storing in a shared space. To "pass" data, which would include launching app B from app A, look into using custom URL schemes. For more complex binary data, you can write files to a common directory using app groups. So maybe be more clear as to what data / how you want to share data between the two apps to get a more clear answer. – wottle Jan 19 '17 at 19:55
  • @wottle basically acceptedRyde is set to false by default in the Driver app. If the driver accepts the ride request that the rider has requested, then once the driver selects Accept, then the value of acceptedRyde is set to true. I have a function in the Rider app that if acceptedRyde == true then the alert appears. ->. This is what I am trying to accomplish.. Would firebase Push Notifications work with these conditions? or would App Groups work? – LizG Jan 19 '17 at 19:59
  • Is the intent that both apps reside on the same device? That sound more like there should be an online value that both a client app and a host app can update / view. It is unlikely that the Uber app used by a rider and an Uber app used by a driver would be running on the same device. If this is for a proof of concept and it really is for inter-app communication, a shared NSUserDefaults would be the best solution here. – wottle Jan 19 '17 at 20:01
  • @wottle No, the apps are on different devices - one for a rider and one for a driver. I am thinking the shared NSUserDefaults would work to but I am unsure as the the value-key part and what goes in it. Any chance you can give me an example with the acceptedRyde scenario? I am assuming that in both apps I need to declare "var userDefaults = NSUserDefaults(suiteName: ) in the View Controller I am trying to access them from/to. – LizG Jan 19 '17 at 20:05
  • Shared NSUserDefaults only works to share information between two apps on the same device. You need the server to maintain the master copy of the data and both the rider and driver apps need to retrieve the latest version of the data (without using cached data). That's a much broader question about creating server side APIs to retrieve and manipulate data. – wottle Jan 19 '17 at 20:08
  • Would push notifications in Firebase work? If there was a condition where if the driver accepted the ride request, a notification would go to the rider? – LizG Jan 19 '17 at 20:10
  • 1
    Yes, you could do a push notification in Firebase. I'm not proficient in Firebase, but that seems like the best approach. – wottle Jan 19 '17 at 20:13
  • thanks for your help, I will submit a firebase question. – LizG Jan 19 '17 at 20:14

0 Answers0