Online or Offline

  • Online or Offline

    Posted by Larry Heimendinger on April 28, 2019 at 7:45 pm
    • Larry Heimendinger

      Member

      April 28, 2019 at 7:45 PM

      @Mr-Dang-MSFT

      I am trying to rollout an app that needs to be aware of online or offline presence.Ā  For example, if the app starts on the device and it has not connectivity, any data submissions need to be saved locally, then on the next app run, if the device is connected, the first activity needs to be to load those saved items and Patch() them into the online SP list.Ā  My code did a LoadData, checked for a row count greater than 0 and if so, Patched() the items online.Ā  Never happens.

      Simply put, if I put that kind of detection into app OnStart, it appears that none of the commands work.Ā  For example I have an image that should display on app start which I control by a variable, let’s say varStarting.Ā  I set it to true as the first command, then to false as the last, but the image never displays, either in a browser or a mobile device (Android phone).

      I have another detection I use, a not visible timer set to 10 seconds.Ā  When it counts down, I check to see if it went from connected to not connected and set a not connected variable.Ā  If that’s all I do, works like a charm.Ā  However, if I tackle things like LoadData() and SaveData(), it doesn’t seem to do anything when it counts down.

      I also know, when the app starts in airplane mode on my phone, it detects that but gives me a message (my message) that data was never saved locally.Ā  I determine that by doing a LoadData(collection, “Saved Data”) followed by If(CountRows(collection)=0,Ā  At app start and on a test screen OnVisible that I get to via a button click, I do a ClearCollect(collection, RealOnlineData) followed byĀ  SaveData(collection, “Saved Data”).Ā  If that runs in a browser I get an error, and if it runs on the device it does not seem to execute:Ā  I display a variable in a label field on a screen for testing that gets a different value after the SaveData(), but it never does.

      Connection.connected is missing a lot, unless there is a lot I have missed I don’t know about.Ā  For example, shouldn’t there be a DeviceMobile or similar thing to let the app know if SaveData() and LoadData() can be run?Ā  If a browser app encounters either of those commands, could they not be treated as NOP commands, just ignored but not stop an execution stream?Ā  And in debugging, why isn’t there a way to see what data has been saved locally if my app can’t get load data to work?

      I found several articles about writing online/offline apps, and their strategies seem to mirror mine.Ā  I had run across an issue last week that this app seemed to behave differently when run from edit mode vs. run as an app, and I discovered the LoadData and SaveData commands were the reason why.

      Desperate for some help. Ā Ā  Thanks in advance.

      ——————————
      Larry Heimendinger
      larry@techevents.com
      Redmond WA
      ——————————

    • Larry Heimendinger

      Member

      April 28, 2019 at 8:49 PM

      @Mr-Dang-MSFT

      I just created a tiny test app to use on my Android phone.Ā  It has two buttons and a text label. Does nothing for app OnStart

      Start button has these commands:

      Collect( colIceCream, { Flavor: “Pistachio”, Quantity: 40 }, { Flavor: “Orange”, Quantity: 200 } );
      Clear(colIceCream);
      Patch(colIceCream,Defaults(colIceCream),{Flavor: “Butter Pecan”, Quantity:10});
      SaveData(colIceCream,”Test1″);
      Patch(colIceCream,Defaults(colIceCream),{Flavor: “Chocolate”, Quantity:10})

      When the app runs and the start button is pressed, a gallery (items=colIceCream) correctly shows Butter Pecan and Chocolate with correct quantities.

      Now the second button does these commands:

      LoadData(colIceCream,”Test1″,false);
      Set(varLoaded,true)

      The screen also shows the varibleĀ varLoadedtue as false when only the start button is pressed.

      SInce I did aĀ SaveData()Ā before IĀ Patched() the Chocolate flavor, i expected the gallery to show just Butter Pecan when I clicked the second button.Ā  It did not, but the varialbe display changed to true.

      This was on my phone device, not doing any offline or online checks, just working on save and load data.Ā  LoadData should have given me an error if there were no save file because I used false in that command, right?

      Really frustrating.

      ——————————
      Larry Heimendinger
      larry@techevents.com
      Redmond WA
      ——————————
      ——————————————-

    Larry Heimendinger replied 6 years, 6 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Online or Offline’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!