Love You App: Texting and Persistence

In this lesson, we discuss a one-click love message app that sends a text to your significant other(s). In the process, you'll learn about the Texting component and user-generated, persistent data.

Texting Component

Demo: Love You App with custom message.

Description: one click method of texting your special loved one.

  1. Add a label, a textbox, a submit button, a send button, a Texting component, and a TinyDB component.
  2. Put default text in label and put a hint in the Textbox
  3. In blocks editor, send button sends the text in label.
  4. Submit button a) change contents of label, and 2) blank out textbox.
  5. Run the app to show that it works. Then explain that if you close and re-run the app, the entered response is gone.
  6. Note: you can send/process texts using wifi and Google Voice, without cell services. Check out this tutorial

Try it, Part 1. Create your own one-click send-a-message app.

Your app should allow a message to be sent to a phone numbers with a single click. It should have the following features:

Persistence

TinyDB component in App Inventor

Demo 2. Adding persistence to your app

  1. Add in code for storing/retrieving from TinyDB. Retrieve in Screen.Initialize. You can store on the send (or a separate button). Careful: TinyDB doesn't work with live testing. To test, download the app to your phone (Package for Phone | Show Barcode or Download to connected phone)
  2. Note that the default message is squashed on first run of the app. Check for this in Screen.Init (check if the length of the text returned is 0).

Try it, Part 2. Add persistence to your app

  1. Add a TinyDB component
  2. In the SubmitButton.Click event, add a call to TinyDB.StoreValue. Tag the data with "loveMessage".
  3. In Screen.Initialize, call TinyDB.GetValue and put the result in the love message label
  4. To test the persistence, you must download the app to your phone (Package | Download to Connected Phone). Do this and test by 1) changing the message, 2) closing the app, and 3) re-opening the app. Your custom message should be there.

Try It, Part 3: Add more lovers to your app

  1. Let the user send the text to three numbers with a single click.
  2. To test, ask three of your classmates for their numbers. You can also test by opening three emulators. The number for an emulator is at top, e.g., 5546
  3. Let the user change the three numbers. Add three labels for the phone numbers, and three PhoneNumberPicker components.
  4. Modify the app so the three chosen phone numbers are persistent
  5. Extra credit: Let the user choose as many phone numbers as desired, instead of just three. You'll need a list for this, see chapter 19 in the book.