Azure Iot Hub Direct Method Call from front end Node.js Website - node.js

I am doing my final year project Using Azure Cloud. I have connected my raspberry pi where I have deployed my python code to trigger the device connected to its GPIO pins. These pins are triggered by "Azure-iot-Hub direct method call". How can I integrate this thing in website? I want to create a button on website and every time when I will press this button the direct method should be called. Is there any way to do this?

Unless creating website is in the scope of project, the easiest option is to use IoT Central, create a device template with associated telemetry, properties and commands.
If creating a custom website, wire the direct method IoT Hub Rest API to your application web page. https://learn.microsoft.com/en-us/rest/api/iothub/service/devices/invoke-method
or use the nodejs service client https://github.com/Azure/azure-iot-sdk-node/blob/main/service/samples/javascript/invoke_command.js
Depending on what web stack you are using, the appropriate SDK can be used (nodejs, python, c#, c or java)

Related

IOT Central Connected Field Service - Send Command

How do you send a command from Field Services to IOT central?
You can create a device, and there is the ability to define a command - but this doesn't connect to IOT central?
I would think you would use flow? But this doesn't use this UI at all?
If you are using a legacy IoT Central app (i.e. not a preview one), you can use this template in Power Automate (previously Flow). In case you haven't done so, this is an excellent tutorial to get started with IoT Central and CFS.
In case you are using the preview features of central, you can use an HTTP request instead of the IoT Central block in Power Automate to use the REST API.

Azure IoT Hub Telemetry Data to Mobile Application

I'm trying to get data from arduino yun to azure iot hub and read data from mobile app. So I created IoT Hub on Azure and able to read telemetry data with nodejs on my computer. It's working good. But trying to create react app for reading data. What should I do for best way to handle this. I must use react native for mobile application part.
Project info:
Load cell reading data, if change then it will provide info to iot hub as telemetry. Then it should inform mobile application created with react native for users.
For testing using button press right now. Main code for load cell will deploy in the future. Sending data from arduino yun to local computer and pushing with nodejs application to Azure.
I manage to solve issue with some escape resolutions:
Used a localhost to get messages from yun and transfer them to iot hub with nodejs backend and libraries.
Used a webapp for visualize. Also now I am able to make a get request from anywhere on my mobile app load. Integrated that in webapp code with endpoint.
Also used websocket to get information from webapp to mobile device.
Created custom png file to show different stats and pressed values to text.
I wish that I can send telemetry from device directly to azure. But couldn't manage to solve that.

Is the Azure notification hub available to use?

We are developing a website and would like to use the Azure portal notification module. Does anyone know what this is built with and if we could implement this on our site rather than building from scratch? We have some some processes that take some time so want users to be able to go off and do other things and come back when it's completed. We host our product on Azure so if this is using an Azure feature then we can use this also.
Azure Notification Hubs provide an easy-to-use and scaled-out push engine that allows you to send notifications to any platform (iOS, Android, Windows, Kindle, Baidu, etc.) from any backend (cloud or on-premises).
Push notifications are delivered through platform-specific infrastructures called Platform Notification Systems (PNSes). They offer barebone push functionalities to deliver a message to a device with a provided handle, and have no common interface. To send a notification to all customers across the Android, iOS, and Windows versions of an app, the developer must work with Apple Push Notification Service(APNS), Firebase Cloud Messaging(FCM), and Windows Notification Service(WNS) separately.
Kindly take a look at the documents to know how it works, scenarios you could leverage Azure Notification Hubs for and how to integrate with your app.
https://learn.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-overview
https://learn.microsoft.com/azure/notification-hubs/notification-hubs-app-service
Do provide more details on your requirement for better assistance.
The question is tagged for Azure Notification Hubs, but the screen shot you showing is for the notification section of the Azure Portal UI. I'm not aware that Microsoft makes the component available for third-party use.
Can you please remove the Notification Hubs tag from this issue as it's not related.

how to integrate getstream.io into cordova / phonegap?

i am using cordova to build native mobile app. I already have an account in stream.
Currently i need to build a feed like facebook into my app and would like to check UI/UX design layout is included in getstream.io ?
Second, how to integrate getstream.io into my cordova app ? is it just copy the getstream.js into my cordova app ?
We don't have any built in user interface, that's entirely up to your application.
We also don't recommend connecting directly to Stream from a mobile application for several reasons. For starters, your API credentials can be easily extracted from the application, which could cost you money if someone abuses your account. Secondly, the socket connections to constantly connect to Stream and read feed updates would use up a lot of battery and data for your users. Better to have your mobile app connect to a back end server, and have that server connect to Stream.

Push notifications on android emulator using Xamarin Forms via Azure Notification Hubs

I am embarking on setting up a Xamarin Forms project for proof of concept with an aim of having an Android app running in the Android emulator registering and receiving google cloud notifications sent via Azure's notification hub.
In researching this I have found some sample code which assumes a backend which uses Microsoft Azure's Mobile Services back end.
I'd prefer not to have a dependency in my client code on Mobile Services backend if possible. However, maybe this is unavoidable (or inadvisable) when using Azure Notification Hubs. That is really the central issue I am raising with this question.
The tutorial linked below shows an approach to register and receive notifications using a Xamarin forms app which is dependent on the Azure Mobile Services backend.
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-forms-get-started-push/
Whereas, this second tutorial shows an approach where the mobile client app (developed using Xamarin Android) registers to the Google messaging cloud rather than Azure notification hubs).
https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote_notifications_in_android/
Where I am coming unstuck is trying to figure out which is the right approach to enabling a Xamarin forms app to register and receive notifications which are pushed via Azure notification hub.
Will the approach of the 2nd tutorial (device registers for push notifications directly with Google cloud) work when notifications are sent via Azure Notification Hubs (configured with the correct API credentials for google messaging) or am I missing something ?
In other words am I making life difficult for myself by adopting the 2nd approach ?
My focus is on developing using Xamarin forms but with Android as the lead device type for initial prototype , proof of concept and then moving on to iOS and Windows Universal 10 at a later stage.
My 2 cents.
The whole point of using Azure Notification Hubs is to abstract away the need to handle Google and iOS push notification systems. Since you are planning to eventually do both iOS and Android, I would suggest registering through Azure.
Azure will handle the iOS feedback channel when registering devices which is nice and you are able to use message templates in Azure which means you can send a single notification hub message and it will be automatically transformed into a message that Android's GCM expects to see and another message that iOS' APNS expects to receive (they both expect different notification message formats).
Since it sounds like no matter which option you choose, you are planning to send messages through Azure, you are going to have to deal with the same Notification Hub limitations, meaning you do not gain much from registering directly through the native server interfaces (limitations in the number of tags a message can have is what I am mainly thinking about).
There is also a library for both platforms if you want to register directly from the device or you can, like we did, have the mobile device call one of your own backend server which can do some initial processing before sending the registration request to azure for the device.
*Edit: Though if you just want to get something working, I do not see a problem with registering directly to GCM and then later on switching out the code to do it through Azure later on.

Resources