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

JSON Error - when attempting to share a tag #58

Closed
jasonm23 opened this issue Feb 3, 2013 · 5 comments
Closed

JSON Error - when attempting to share a tag #58

jasonm23 opened this issue Feb 3, 2013 · 5 comments

Comments

@jasonm23
Copy link

jasonm23 commented Feb 3, 2013

Not an Issue report, just a helpful pointer when the JSON Error pops up when writing or sharing a tag, it's due to the follow user error writing the method signature for nfc.share or nfc.write

 var record = ndef.textRecord("or any other ndef record creation method.");
 nfc.share(record,  onSuccessFunc, onFailFunc); // this will throw a JSON Error

The record must be in an array, ie.

 var record = ndef.textRecord("or any other ndef record creation method.");
 nfc.share( [ record ] ,  onSuccessFunc, onFailFunc); 
 //         ⬆       ⬆ 

If this was an issue report (it's a bit late since this will already be used in implementation details downstream.) it'd be a suggestion to remove the array syntax (unless multiple tags are sharable/writable at once? @don possible?)

@don
Copy link
Member

don commented Feb 4, 2013

This method signature is correct. The documentation needs to be clarified.

nfc.write and nfc.share only write one NdefMessage, but an NdefMessage is an array of NdefRecords.

Helper methods like ndef.textRecord create a new NdefRecord, but a message is one or more NdefRecords, so the method takes and array of records.

@don
Copy link
Member

don commented Feb 5, 2013

Created #59 to update documentation

@don don closed this as completed Feb 5, 2013
@alejandrochacinortega
Copy link

@don @jasonm23 do you have an example of how to implement the nfc.share function?
I have been trying to do it and it does not transfer anything. I am using ionic and angular.

Thanks in advance

@don
Copy link
Member

don commented Feb 11, 2015

@mobileComputingNITH try https://github.com/don/nfc-share

@alejandrochacinortega
Copy link

Thanks Dan for the suggestion! :)

You have done such a great job writing that plugin.

On Wed, Feb 11, 2015 at 8:47 PM, Don Coleman notifications@github.com
wrote:

@mobileComputingNITH https://github.com/mobileComputingNITH try
https://github.com/don/nfc-share


Reply to this email directly or view it on GitHub
#58 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants