Launch App message and records

Launch App library provides a way to create NFC messages capable of launching Android or iOS applications.

Overview

Launch App message contains two records: URI record and Android Launch App record. Typically, the URI record contains a Universal Link used by iOS and the Android record contains an Android package name. The Universal Link is a link associated to the application.

Implementation

The Launch App records module provides functions for creating the record, and the Launch App messages module provides functions for creating and encoding the message.

The following code snippets show how to generate a Launch App message.

  1. Define the Universal Link string, Android package name string and create a buffer for the message:

    /* Package: no.nordicsemi.android.nrftoolbox */
    static const uint8_t android_pkg_name[] = {
    	'n', 'o', '.', 'n', 'o', 'r', 'd', 'i', 'c', 's', 'e', 'm', 'i', '.', 'a', 'n', 'd', 'r',
    	'o', 'i', 'd', '.', 'n', 'r', 'f', 't', 'o', 'o', 'l', 'b', 'o', 'x' };
    
    /* URI nrf-toolbox://main/ */
    static const uint8_t universal_link[] = {
    	'n', 'r', 'f', '-', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', '/', '/', 'm', 'a', 'i', 'n',
    	'/'};
    
  2. Create the Launch App message:

    int err;
    
    err = nfc_launchapp_msg_encode(android_package_name,
                                sizeof(android_package_name),
                                universal_link,
                                sizeof(universal_link),
                                ndef_msg_buf,
                                &len);
    
    if (err < 0) {
         printk("Cannot encode message!\n");
         return err;
    }
    

    Provide the following parameters:

    • Android package name string

    • Length of Android package name string

    • Universal Link string

    • Length of the Universal Link string

    • Message buffer

    • Size of the available memory in the buffer

Supported features

The library supports encoding AAR (Android Application Record) and Universal Links into NFC message.

Samples using the library

The NFC: Launch App sample uses this library.

Dependencies

API documentation

Launch App messages

Header file: include/nfc/ndef/launchapp_msg.h
Source file: subsys/nfc/ndef/launchapp_msg.c
Launch App messages

Launch App records

Header file: include/nfc/ndef/launchapp_rec.h
Source file: subsys/nfc/ndef/launchapp_rec.c
Launch App records