App Inventor Extensions


SMS Receiver Extension SDK 34 ready!

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor community. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Jul 3th, 2024: Version 1: initial version.

Apr 24th, 2025: Version 2: Send Sms functionality and OnReceive background event handler added to forward received SMS

Description

SMS Receiver extension.
Use this extension to receive SMS while your app is not running. The including background functionality in Version 2 offers to forward received SMS by sending it to another number or forwarding it by email, etc. You have 4 different possibilities to trigger an action after an SMS has received depending on property StartMode

  1. Only Notification
    Display a notification. After clicking the notification, the app will be started and screen "LockScreen" will be opened. In case that screen does not exist, Screen1 will be opened.
  2. Start Above Lock Screen or Notification
    If the device is locked, the screen called "LockScreen" of the app will be opened above the lockscreen of the device! After closing the app, the device still will be locked. If the device is unlocked, display a notification. After clicking the notification, the app will be started and screen "LockScreen" will be opened. This is the recommended start mode to not disturb the user while using other apps, see also here.
  3. Start Always
    The app will always start and open the screen called "LockScreen" no matter the state of the device. This might be annoying if the user is in a phone call or using another app. For this mode, additionally the permission "Appear On Top" is required.
  4. Only Background Processing
    Trigger some background functionality to forward the received SMS.

Note: Displaying an app above the lockscreen (also known as full screen intent) requires for Android 14+ devices additionally full screen intent permission. After each app update this permission needs to be refreshed again! Its use is restricted: For apps targeting Android 14 (API level 34) or higher, apps that are allowed to use this permission are limited to those that provide calling and alarms only. You can use method HasFullScreenIntentPermission to check if your app has the permission; if not or if your app has not been approved for default enabling use of full screen intents you can use method AskForFullScreenIntentPermission to launch the settings page where users can grant the permission.

Required permissions: android.permission.RECEIVE_SMS, android.permission.SYSTEM_ALERT_WINDOW, android.permission.POST_NOTIFICATIONS, android.permission.DISABLE_KEYGUARD, android.permission.WAKE_LOCK, android.permission.USE_FULL_SCREEN_INTENT
In version 2 android.permission.SEND_SMS has been added to forward received sms to another number.

Note: To publish an app in Google Play using the sensitive permission RECEIVE_SMS or SEND_SMS might be a challenge. You have to find a good use case, see also here.

Properties


Reference screen for Itoo where the procedure 'OnReceive' exists. If no property is set, the extension will take "Screen1" as the reference by default.

OnReceive has the arguments phoneNumber and message.

Note: The OnReceive event handler also will be called if the app is in the foreground!


Returns/Specifies the notification color.


Returns/Specifies the SmallIcon for notification. Recommended size is 96x96.


StartMode after SMS has been received.
Possible values are: 1, 2,3 or 4. (1 = Only notification, 2 = Start Above Lock Screen or Notification, 3 = Start Always, 4 = Only Background Processing).

Methods


Returns true, if receive sms permission has been granted, else false.


Returns true, if send sms permission has been granted, else false.


Ask for both RECIVE_SMS and SEND_SMS permissions.


Returns true, if post notifications permission has been granted, else false. Required starting from API Level 33.


Ask for Post Notifications permission. Required starting from API Level 33.


If user likes to always start the app, special permission is required. Using this method, you can check, if the permission has been granted.


Open Appear On Top Settings to enable always starting the app. Required starting from API Level 23.


Returns true, if full screen intent permission has been granted, else false. Required starting from API Level 34.


Ask for Full Screen Intent permission. Required starting from API Level 34 for apps that did not complete the Google Play declaration or have not been approved for default enabling use of full screen intents.


Cancel the current notification.


Sends a text message via SMS.

Events


Event indicating that sms has been sent.

Example App: Receive SMS

Blocks Screen1




Blocks LockScreen


Screenshots

The example app gives a short overview about its purpose and asks for 2 basic permissions to receive sms and post notifications







Depending on the start mode, further permissions are required. Both Start Modes "Start Above Lock Screen or Notification" and "Start Always" require Full Screen Alert permission. Start Mode "Start Always" requires Allways On Top permission.







Itoo integration

Itoo is a powerful framework to execute blocks in the background. Version 2 of the sms-receiver extension uses the itoox-wrapper library and provides the new OnReceive event handler (which looks like a procedure). By default the event handler is located in Screen1. But you can set the property ReferenceScreen (see documentation below) to use the event hanlder on a different screen.

The background event handler will be called from Itoo from the background after an a SMS has been received. You will have to create the procedure using the name OnReceive. That procedure must have 2 arguments, else it will not work. Note: This background event handler also will be called if the app is in the foreground.


Now we can execute almost any synchronous logic in the background (no user interface components) after a sms has been received. This currently is restricted to synchronous methods, i.e. methods which return something in an event (for example the web component) will not work. Please be aware, that there is no user interface available in the background.

Preconditions for using the OnReceive event handler together with Itoo

  • You should already have some experience in App Inventor and understand the basics. If you are new, then first learn App Inventor and come back later for these advances features. Alternatively you can contact me by email to get personal support for a small fee. As beginner you already can use the sms-receiver extension without the OnReceive event handler!
  • You are familiar with the Do it debugging functionality of App Inventor.
  • You are familiar with using Logcat. To find possible errors of your blocks in the background, let me suggest to filter the logcat output for the tags TaifunSmsReceiver, Notifier, ItooCreator and System.err.

Guidelines for using Itoo

  • First get your background functionality running in the foreground. Like this, you can find errors much easier. And as soon as you got it working in the foreground, then test it in the background.
  • Read the complete Itoo to leaarn how Itoo works and try the example projects, See also the battery checker tutorial and notification listener and itoo tutorial.
  • Do not use global variables while in the background, use local variables instead
  • Do not use any user-visible or UI components in the background
  • In the background, use the Itoo StoreProperty/FetchProperty methods rather than TinyDB. TinyDB relies on SharedPreferences which will not ensure data synchronization across background processes.

Example blocks for background processing: forward sms to another phone number


Example blocks for background processing: forward sms by email

The example uses my mail extension to send the email. This extension can be purchased seperately here.

Test

Tested successfully on Samsung Galaxy A54 running Android 14 and Google Nexus 5X running Android 8.1.

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Buy the SMS Receiver extension for App Inventor


You can buy this extension (aix file).
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 15 USD via Paypal
to Pura Vida Apps

PayPal - The safer, easier way to pay online!

2. Bitcoin

Then send me the transaction id by email and tell me the extension you are interested in.

After having received your payment I will be happy to send the download link to you. Please let me know your Google account! I usually will send the download link not later than 24 hours after having received your payment.
Thank you! Taifun



After buying the extension you additionally will receive the following projects

Terms and Conditions

Back to top of page ...


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact