NFC / NDEF Library for Proximity APIs  4.1.0
Easily parse and create NDEF records with the Windows Proximity APIs / Near Field Communication NFC.
Public Member Functions | Static Public Member Functions | Properties | List of all members
NdefLibrary.Ndef.NdefLaunchAppRecord Class Reference

Handles the Windows LaunchApp record format. More...

Inheritance diagram for NdefLibrary.Ndef.NdefLaunchAppRecord:
NdefLibrary.Ndef.NdefRecord

Public Member Functions

 NdefLaunchAppRecord ()
 Create an empty LaunchApp Record. More...
 
 NdefLaunchAppRecord (NdefRecord other)
 Create a LaunchApp record based on the record passed through the argument. More...
 
void AddPlatformAppId (string platform, string appId)
 Add another platform and app ID. More...
 
void SetPayloadAndParse (byte[] payload, bool parseNewPayload)
 Sets the payload of the base class to the byte array from the parameter and optionally parses its contents. More...
 
override bool CheckIfValid ()
 Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue. More...
 
- Public Member Functions inherited from NdefLibrary.Ndef.NdefRecord
 NdefRecord ()
 Create an empty record, not setting any information. More...
 
 NdefRecord (TypeNameFormatType tnf, byte[] type)
 Create a new record with the specified type name format and type. Doesn't set the payload and ID. More...
 
 NdefRecord (NdefRecord other)
 Create a new record, copying the information of the record sent through the parameter. More...
 
Type CheckSpecializedType (bool checkForSubtypes)
 Checks the type name format and type of this record and returns the appropriate specialized class, if one is available and known for this record type. More...
 

Static Public Member Functions

static bool IsRecordType (NdefRecord record)
 Checks if the record sent via the parameter is indeed a LaunchApp record. Only checks the type and type name format, doesn't analyze if the payload is valid. More...
 

Properties

string Arguments [get, set]
 Arguments that will be passed to the launched application. More...
 
Dictionary< string, string > PlatformIds [get]
 Platform names and respective app IDs. More...
 
- Properties inherited from NdefLibrary.Ndef.NdefRecord
TypeNameFormatType TypeNameFormat [get, set]
 Indicates the structure of the value of the TYPE field. More...
 
virtual byte [] Type [get, set]
 An identifier describing the type of the payload. More...
 
byte [] Id [get, set]
 An identifier in the form of a URI reference. More...
 
virtual byte [] Payload [get, set]
 The application data carried within an NDEF record. More...
 

Additional Inherited Members

- Public Types inherited from NdefLibrary.Ndef.NdefRecord
enum  TypeNameFormatType {
  TypeNameFormatType.Empty = 0x00, TypeNameFormatType.NfcRtd = 0x01, TypeNameFormatType.Mime = 0x02, TypeNameFormatType.Uri = 0x03,
  TypeNameFormatType.ExternalRtd = 0x04, TypeNameFormatType.Unknown = 0x05, TypeNameFormatType.Unchanged = 0x06, TypeNameFormatType.Reserved = 0x07
}
 Standardized type name formats, as defined by the NDEF record specification from the Nfc Forum. More...
 
- Protected Attributes inherited from NdefLibrary.Ndef.NdefRecord
byte [] _type
 Byte array storing raw contents of the type. Use Type property to access it whenever possible. More...
 
byte [] _payload
 Byte array storing raw contents of the payload. Use Payload property to access it whenever possible. More...
 

Detailed Description

Handles the Windows LaunchApp record format.

The Proximity APIs can directly write LaunchApp tags using a specific API call. However, this doesn't allow flexibility in including this record together with other records on a tag, to allow for greater flexibility.

A LaunchApp record created using this class can be put into a multi-record NDEF message. This allows creating a tag that contains both the Windows LaunchApp tag, as well as the Android Application Record.

Note that for default handling by the OS, the Windows LaunchApp tag needs to be the first record in the message. Android recommends to put its Android Application Record (AAR) as the last record of the message.

To create a LaunchApp tag using the Windows Proximity APIs, you have to pass a string containing the arguments and platform/app ID tuples in a special format (separated by tabs). The APIs then re-format the text into the actual payload of the record - meaning that the string you send to the Proximity LaunchApp Write API does NOT get directly written to the tag.

In contrast, this class provides a more convenient way to set the arguments and to add any number of platforms; all using properties or methods, without the need to worry about formatting a special string. This class will then directly create the required raw payload that is suitable to be written to the tag.

Constructor & Destructor Documentation

◆ NdefLaunchAppRecord() [1/2]

NdefLibrary.Ndef.NdefLaunchAppRecord.NdefLaunchAppRecord ( )

Create an empty LaunchApp Record.

◆ NdefLaunchAppRecord() [2/2]

NdefLibrary.Ndef.NdefLaunchAppRecord.NdefLaunchAppRecord ( NdefRecord  other)

Create a LaunchApp record based on the record passed through the argument.

Internalizes and parses the payload of the original record. The original record has to be a LaunchApp Record as well.

Parameters
otherRecord to copy into this LaunchApp record.
Exceptions
NdefExceptionThrown if attempting to create a LaunchApp record based on an incompatible record type.

Member Function Documentation

◆ AddPlatformAppId()

void NdefLibrary.Ndef.NdefLaunchAppRecord.AddPlatformAppId ( string  platform,
string  appId 
)

Add another platform and app ID.

A valid LaunchApp tag needs to contain at least one platform / app ID tuple. The platform name needs to be unique. Each platform name + app ID has to be smaller or equal to 255 characters. If known, the appID will be checked for semantic correctness.

Parameters
platformName of the platform, e.g., Windows or WindowsPhone.
appIdID of the platform. See platform documentation on how to format the platform ID.

◆ CheckIfValid()

override bool NdefLibrary.Ndef.NdefLaunchAppRecord.CheckIfValid ( )
virtual

Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue.

Exceptions
NdefExceptionThrown if no valid NDEF record can be created based on the record's current contents. The exception message contains further details about the issue.
Returns
True if the record contents are valid, or throws an exception if an issue is found.

Reimplemented from NdefLibrary.Ndef.NdefRecord.

◆ IsRecordType()

static bool NdefLibrary.Ndef.NdefLaunchAppRecord.IsRecordType ( NdefRecord  record)
static

Checks if the record sent via the parameter is indeed a LaunchApp record. Only checks the type and type name format, doesn't analyze if the payload is valid.

Parameters
recordRecord to check.
Returns
True if the record has the correct type and type name format to be a LaunchApp record, false if it's a different record.

◆ SetPayloadAndParse()

void NdefLibrary.Ndef.NdefLaunchAppRecord.SetPayloadAndParse ( byte []  payload,
bool  parseNewPayload 
)

Sets the payload of the base class to the byte array from the parameter and optionally parses its contents.

The parsing needs to be done when the LaunchApp record is read from a tag. If a detail of an existing LaunchApp class is modified, it will just update its internal payload, but doesn't need to parse it again (as the details are already stored in the respecitve member variables).

Parameters
payloadnew payload
parseNewPayloadwhether to parse the new payload to update the internal data properties

Property Documentation

◆ Arguments

string NdefLibrary.Ndef.NdefLaunchAppRecord.Arguments
getset

Arguments that will be passed to the launched application.

The exact format is up to the app itself. The arguments string must not be empty; otherwise, the reading device might ignore the LaunchApp record.

◆ PlatformIds

Dictionary<string, string> NdefLibrary.Ndef.NdefLaunchAppRecord.PlatformIds
get

Platform names and respective app IDs.

The key is the platform name, the value the app ID for this specific platform. A valid LaunchApp tag needs to contain at least one platform / app ID tuple. The platform name needs to be unique. Each platform name + app ID has to be smaller or equal to 255 characters.


The documentation for this class was generated from the following file: