This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the home you created earlier | |
let homeName = home.name; | |
// ask the user for a name and add it to HomeKit | |
prompt(`Name the room to add to ${homeName}`).then((promptResult: PromptResult) => { | |
if (promptResult.result) { | |
homekit.addRoomToHome(promptResult.text, homeName).then( | |
(room: Room) => console.log(`Added room ${room.name} to home ${homeName}`), | |
err => alert(err) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// start searching | |
homekit.startSearchingForAccessories( | |
// event handler which is triggered when a new accessory is found | |
(accessory: Accessory) => { | |
console.log(`New accessory found: ${accessory.name}`); | |
// once found you can assign it to a home | |
homekit.addAccessoryToHome(accessory.name, homeName) | |
.then(added => console.log(`Added? ${added}`)); | |
}, | |
// event handler which is triggered when an accessory was removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import a few Classes we're gonna use | |
import { Accessory, Service, Characteristic } from 'nativescript-homekit'; | |
// given an accessory.. | |
let accessory: Accessory = myPreviouslyFoundAccessory; | |
// .. you can now list its services.. | |
accessory.services.forEach((s: Service) => { | |
console.log(`Service ${s.name} of type ${s.type} has ${s.characteristics.length} characteristics`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wantEmailReceiptChanged(args: PropertyChangeData): void { | |
if (!args || args.propertyName !== "checked") { | |
return; | |
} | |
if (args.value) { | |
// switched on | |
} else { | |
// switched off | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class PinComponent implements OnInit { | |
// according to Apple's documentation ID 4 is the value 'numberPad' of their keyboard type enum | |
const IOS_KEYBOARDTYPE_NUMBERPAD: number = 4; | |
// assuming you have a TextField / TextView with '#pincodeField' in your view | |
@ViewChild("pincodeField") pincodeField: ElementRef; | |
ngOnInit(): void { | |
if (this.pincodeField.nativeElement.ios) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NSNUMKEY_DIRECTIVES } from "nativescript-numeric-keyboard/angular"; | |
declarations: [ | |
NSNUMKEY_DIRECTIVES, | |
// any other declarations | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackLayout> | |
<Label [text]="appVersion"></Label> | |
</StackLayout> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adding this line to your app... | |
var uuid = require('node-uuid'); | |
console.log("uuid.v1: " + uuid.v1()); | |
// ... leads to a crash (triggered by that first line) and this error being logged: | |
// error: file:///app/tns_modules/node-uuid/./uuid.js:121:24: JS ERROR TypeError: _rng is not a function. (In '_rng()', '_rng' is undefined) | |
// ... which is caused by these lines in uuid.js: | |
var _rb = require('crypto').randomBytes; | |
_rng = _rb && function() {return _rb(16);}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adding this line to your app... | |
var uuid = require('node-uuid'); | |
console.log("uuid.v1: " + uuid.v1()); | |
// ... no longer leads to a crash but this output instead: | |
// uuid.v1: f7c65940-fe57-11e6-a543-e5004118dcb5 | |
// ... which is because the plugin changed this line in uuid.js: | |
var _rb = require('crypto').randomBytes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
"buffer": "4.9.1", | |
"querystring": "0.2.0", | |
"sax": "1.1.5", | |
"uuid": "3.0.0", | |
"xml2js": "0.4.15", | |
}, | |
"main": "lib/aws.js", | |
"browser": { | |
"lib/aws.js": "./lib/browser.js", |