Comments (14)
Oh cool!
from nativescript-nfc.
I've added code to do a little PoC of this feature, but in my tests (on line 165) nfcNdefTag.writeNDEFCompletionHandler
is undefined
.
Here's the (commented) code.. feel free to play with it:
nativescript-nfc/src/nfc.ios.ts
Lines 150 to 171 in d4414b3
from nativescript-nfc.
Maybe it's somehow connected to NativeScript/ios-jsc#1251 ? There is also native object transforms to JS without needed methods. I've tested app with latest version of ios-platform (that consist fix of that error) - nfcNdefTag.writeNDEFCompletionHandler still undefined :(
from nativescript-nfc.
I'm trying to use your snippet. While the readerSessionDidDetectTags
is called, the tags
input parameter is undefined. I'm not sure why. I've tried with both empty and non-empty tags
from nativescript-nfc.
Looking forward to this working
from nativescript-nfc.
Do you guys need any help? I need this feature and may be you've already made some progress or I can start working on this.
from nativescript-nfc.
No progress. iOS write to NFC still dosent work for me
from nativescript-nfc.
Check this out: https://github.com/chariotsolutions/phonegap-nfc
The problem is that beginSession() is used instead of scanNdef().
"On iOS, the user must start a NFC session to scan for a tag. This is different from Android which can constantly scan for NFC tags. The nfc.scanNdef and nfc.scanTag functions start a NFC scanning session. The NFC tag is returned to the caller via a Promise. If your existing code uses the deprecated nfc.beginSession, update it to use nfc.scanNdef."
They recently fixed this on phonegap-nfc: chariotsolutions/phonegap-nfc@a3b1e3a
from nativescript-nfc.
A PR would be very much appreciated!
from nativescript-nfc.
Sure, but it will take time as I don't have the dev env set up for iOS. I am developing for Android now. I am happy to help. I've never done a PR in my life, but I am eager to learn :D
from nativescript-nfc.
Perhaps we have to call queryNDEFStatus before trying writeNDEF as per https://developer.apple.com/documentation/corenfc/nfcndeftag/3075574-writendef?language=objc. Found this native Swift sample app code for iOS
func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) {
if tags.count > 1 {
session.alertMessage = "More than 1 tags found. Please present only 1 tag."
self.tagRemovalDetect(tags.first!)
return
}
// You connect to the desired tag.
let tag = tags.first!
session.connect(to: tag) { (error: Error?) in
if error != nil {
session.restartPolling()
return
}
// You then query the NDEF status of tag.
tag.queryNDEFStatus() { (status: NFCNDEFStatus, capacity: Int, error: Error?) in
if error != nil {
session.invalidate(errorMessage: "Fail to determine NDEF status. Please try again.")
return
}
if status == .readOnly {
session.invalidate(errorMessage: "Tag is not writable.")
} else if status == .readWrite {
if self.ndefMessage!.length > capacity {
session.invalidate(errorMessage: "Tag capacity is too small. Minimum size requirement is \(self.ndefMessage!.length) bytes.")
return
}
// When a tag is read-writable and has sufficient capacity,
// write an NDEF message to it.
tag.writeNDEF(self.ndefMessage!) { (error: Error?) in
if error != nil {
session.invalidate(errorMessage: "Update tag failed. Please try again.")
} else {
session.alertMessage = "Update success!"
session.invalidate()
}
}
} else {
session.invalidate(errorMessage: "Tag is not NDEF formatted.")
}
}
}
}
But I dont know how to implement this in Nativescript :D
from nativescript-nfc.
@EddyVerbruggen: I've done good progress on implementing writeTag for iOS, it actually works, please check here: https://github.com/demetrius-tech/nativescript-nfc/blob/dev-ios-write-uid/src/nfc.ios.ts
Kindly support me in finding a solution for getting the UID #55 I'm pretty desperate.
from nativescript-nfc.
@demetrius-tech - what is the status of this feature? it seems that we'll have to add some obj-c code to make it work?
Is that the latest development? Can I hire you to consult on some realtime questions as we try to impliment this?
Please email me your skype or google/chat info. [email protected]
from nativescript-nfc.
@timh5 it was working in the past, with version 7. Let me check if I committed the code in my repo and I will support you for free, as I don't have much time for other projects.
from nativescript-nfc.
Related Issues (20)
- ": java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptNfcActivity"
- Cannot add plugin for local build HOT 1
- Angular Demo from local plugin won't scan tag HOT 1
- possibility to undo setOnNdefDiscoveredListener HOT 2
- detect error for iOS
- iOS 14 / AppStore : NDEF is disallowed HOT 2
- Angular Demo
- NFCNDEFTag.prototype.queryNDEFStatusWithCompletionHandler is undefined HOT 5
- readerSessionDidDetectNDEFs is not being called HOT 1
- Supported ISO communication standards
- NativeScript -NFC HOT 1
- Callback not executed on iOS 14 and NS 8 HOT 3
- Callback not initiating on ios 14.6 with ns 8 HOT 4
- Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
- does not work with svelte native HOT 1
- Demo App not compatible with NativeScript CLI 8.1.4 on Mac
- Reading NfcNdefData on iOS throws Exception
- Bounty for write function in IOS HOT 2
- Crashing due to PendingIntent flag HOT 2
- callback not work on android with ns 8.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-nfc.