The next code shows the Run approach to the backdrop task and just how it determines the Cortana command which was spoken through the user.
since our background job for handling Cortana instructions runs asynchronous techniques. With no deferral, iphone developer possible for that Run approach to return prior to the background task has completed its work, that might increase the risk for suspension or termination from the background task host process and stop the conclusion associated with a asynchronous procedures began through the background task. For additional particulars about deferrals, begin to see the IBackgroundTaskInstance.GetDeferral method documentation on MSDN.
A lot of the instructions we implemented fairly simple, but we did decide to get one command that needed Cortana to prompt the consumer to acquire more information. Whenever a user asks Cortana to alter the lights’ color, but didn’t specify one, iphone developer would have liked Cortana to point out some colors. Which was accomplished via a request disambiguation as proven within the following code.
Find out more at https://blogs.home windows.com/buildingapps/2016/04/20/adding-cortana-and-bluetooth-to-a-uwp-application-for-phillips-hue/#ljTdAJW413F6rC6a.99And really that’s all there’s into it. Individuals would be the basics of applying Cortana support within an application.
Adjusting the lights with UI controls is really a vast improvement over physical switches, but we should also explore methods to control the lights using closeness – once the user comes within reasonable selection of the lights using their phone, the lights should instantly switch on. Once they leave, the lights switch off. To do this effect, we made the decision to make use of Bluetooth Low Energy (LE) because it’s power-friendly and may easily run without anyone’s knowledge.
Bluetooth LE relies around writer and watcher objects. A writer constantly broadcasts signals for nearby listening watchers to get. A watcher, however, listens for nearby marketers and fires occasions if this gets to be a Bluetooth LE advertisement so the application can react accordingly. Within our situation, the world thinks there is a device serving as a writer in close closeness towards the Hue bridge. The application (running on the phone within the user’s pocket) assumes the function from the watcher.