Prerequisite knowledge

Basic familiarity with building mobile apps on Adobe AIR, including familiarity with Adobe Native Extensions.

Required third-party products

Microsoft Visual Studio 2015

User level



Toasts allow your app to provide time-sensitive or personally relevant notifications to users regardless of whether they are in another app or screen.

An AIR app can construct a toast notification and deliver to the user at appropriate times. The notification is capable of sending events to the native code which can then be delivered back to ActionScript and then the AIR developer can take appropriate actions. Windows Notifications look like below. For example: you could use a toast to inform about recent installation completion.

The Windows Toast Notification Native Extension allows the AIR developer to send out local toast notifications and capture events respective to whether the user has dismissed, clicked or the toast auto dismissed. 

The attached ZIP file contains:

  • A directory called Native Code: This is the project which would require Visual Studio 2015. This also contains the ActionScript glue code that couples with the Native Extension and generates the swc file.
  • A directory called ActionScript Code: This directory includes the sample Flex project that uses the ANE for Toast generation.

The ActionScript Library

The ActionScript library contains the class WindowsExtensionWrapper that contains the following API to generate the Toasts:

public function displayToast(String lineOne, String lineTwo, String lineThree): void

The AIR application can create many instances of this class. However, they will all use the single ANE code for toast generation.

Setting up the project

  1. To use the Toast ANE, you need to create a sample AIR application (also attached in the ActionScript directory).
  2. Add reference of the ANE in your Flash Builder project.
  3. Right-click to the project, chose Properties, and then select Build Path and then click on Native Extensions Tab.
  4. Add your ANE by clicking on browse and then choosing the ane to include. 

5. Click on Build Packaging and click on Native Extensions Tab. Check against the required ANE that has to be packaged.

The Windows Native Library

The generation of Toast through ANE is delegated to Windows.

This section explains the classes that are present in the source code.

The main entry point for the ANE for AIR is the dllMain.cpp class. The ExtensionInitializer() and ExtensionFinalizer() sets the contextInitializer and contextFinalizer which are also functions in the cpp.

The contextInitializer() sets the functions that are exposed to AIR runtime for calling. The contextFinalizer() just returns (in this example).

The displayToast() function is the method that the AIR runtime would call and it does the work of generating toast. It takes three arguments which are the three lines of the toast to be displayed. It processes the arguments and calls the displayToast() function of the DesktopToastsApp class.

The DesktopToastsApp class has functions that prepare the environment required for the Toast and generates the toast as well. The TryCreateShortcut() creates a shortcut and installs it using the InstallShortcut() function.

The toast to be displayed, needs an XML input which specifies the attributes of the toast such as the lines text to be displayed, image etc.

The DisplayToast() function creates and XML using CreateToastXml() function and then passes the XML to CreateToast() function which creates the toast and delegates the ToastEventHandler class to listen to events that will be generated, such as user dismissal, auto dismissal, or user click of the Toast.

For a sample on Sending Toast Notification, see Sending toast notifications from desktop apps sample

Where to go from here

For more information about developing native extensions for Adobe AIR, see:

For more information about using a native extension in an AIR application, see: