URN format for a TNF
My question is about the right format for the TNF_EXTERNAL_TYPE URN in an NDEF tag: should it be "com.mydomain.mydivision" or "mydivision.mydomain.com"?
The Android NFC guide states, for TNF_EXTERNAL_TYPE NDEF records:
URI based on the URN in the type field. The URN is encoded into the NDEF type field in a shortened form: (domain_name):(service_name)
and from what I understand, URNs/URIs follow the "mydivision.mydomain.com" convention (am I wrong here?)
But they write later, in the examples:
String domain = "com.example"; //usually your app's package name
And just a little further, they write:
URNs for TNF_EXTERNAL_TYPE have a canonical format of: urn:nfc:ext: example.com :externalType
So I do not know what to think here. What is the correct format? I would appreciate quotes from the specification if there is any.
The correct format is
urn:nfc:ext:<DOMAIN>:<TYPE_NAME>
where <DOMAIN>
is defined as
the domain name of the issuing organization
and <TYPE_NAME>
is a case-insensitive type name string managed by that organization.
The NFC Forum Record Type Definition specification (as of version 1.0) does not clearly define any rules for the format of the domain name. However, all examples given in the specification use the format for domain names as described in RFC 1034. (This also makes sense since the specification refers to RFC 3986 for URI syntax, which in turn also refers to RFC 1034 for the format of domain names.)
Hence, the least specific component of the domain name comes last and, therefore, you should use the format " mydivision.mydomain.com ".
Also note that Android's intent filter mechanism is case-sensitive while the external type name is case-insensitive. To avoid problems, you should, therefore, only use lower-case letters in the type name.
链接地址: http://www.djcxy.com/p/12090.html下一篇: URN格式为TNF