Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method to create an Android Application Record (AAR) #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions NdefMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ void NdefMessage::addUriRecord(String uri)
delete(r);
}

void NdefMessage::addAndroidApplicationRecord(char *packageName)
{
NdefRecord* r = new NdefRecord();
r->setTnf(TNF_EXTERNAL_TYPE);

char *RTD_AAR = "android.com:pkg"; // TODO this should be a constant or preprocessor
r->setType((uint8_t *)RTD_AAR, strlen(RTD_AAR));

r->setPayload((uint8_t *)packageName, strlen(packageName));

addRecord(*r);
delete(r);
}

void NdefMessage::addEmptyRecord()
{
NdefRecord* r = new NdefRecord();
Expand Down
10 changes: 10 additions & 0 deletions NdefMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ class NdefMessage
void addTextRecord(String text);
void addTextRecord(String text, String encoding);
void addUriRecord(String uri);

/**
* Creates an Android Application Record (AAR) http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar
* Use an AAR record to cause a P2P message pushed to your Android phone to launch your app even if it's not running.
* Note, Android version must be >= 4.0 and your app must have the package you pass to this method
*
* @param packageName example: "com.acme.myapp"
*/
void addAndroidApplicationRecord(char *packageName);

void addEmptyRecord();

unsigned int getRecordCount();
Expand Down