WebAPI/WebNFC: Difference between revisions

Line 349: Line 349:


== NDEF P2P SendFile Example ==
== NDEF P2P SendFile Example ==
In order to send a file,
During handover scenarios, in order to send a file
   var nfcdom = window.navigator.mozNfc;
   var nfcdom = window.navigator.mozNfc;
   nfcdom.onpeerready = function(event) {
   nfcdom.onpeerready = function(event) {
     var nfcPeer = nfcdom.getNFCPeer(event.detail);
     var nfcPeer = nfcdom.getNFCPeer(event.detail);
     // Below is only an example to illustrate that sendfile accepts 'blob'.
     var blob = ... // construct a 'blob' that is of type 'file'.
     var fakeBlob = new Blob([], {type: 'image/png'});
     // This 'blob' will be passed onto / handover to Bluetooth interface for the actual file transfer. (Wifi handover is not yet supported)
     var req = nfcPeer.sendFile(fakeBlob);
     var req = nfcPeer.sendFile(blob);
     req.onsuccess = function(e) {
     req.onsuccess = function(e) {
       console.log("Successfully sent file");
       console.log("Successfully sent file");
Line 363: Line 363:
     };
     };
   };
   };
Note: 'blob' that is being passed by nfc gaia applications should be of the type / represent 'file object'. This 'blob' will be passed onto / handover to Bluetooth interface for the actual file transfer. (Wifi handover is yet to be supported)


== Handover Support ==
== Handover Support ==
Confirmed users
118

edits