xamarin Forms Azure Notification Hubs - azure

everyone,
i have developed an app with Xamarin Forms and i want to implement Push Notification.
I use Azure Notificatio hubs to implement push notification.
I can now receive the push notification in my app but I want to group the push notification (send push notification to determine device)
I want the user to select certain category to receive notification.
but the documentation from Microsoft, does not explain how to do this. the documentation said how to implement push notification with Java, Swift (Native App).
but i want to do everything with C#, because i use Xamarin forms.
can someone please help me???

You could use Routing and Tag Expressions, Which enable you to target specific sets of devices, or more specifically registrations, when sending a push notification through Notification Hubs.
Tags can be used to subscribe to message categories such as news, sports, and weather. For simplicity, the sample application defines a default template with a single parameter called messageParam and a single tag called default. In more complex systems, user-specific tags can be used to message a user across devices for personalized notifications. To learn more about tags, see Routing and tag expressions.
For more details you could refer the docs .

Related

Push Notification with GetStream Notification feed

We are currently using getStream in our react web application for notification feed. It is working fine.
We are now planning to use it in our react native mobile app as well. We would like to show a notification (in the top tray or drawer) whenever there is a notification received by a user, similar to how we get in whatsapp or telegram
Does anyone know how this can be achieved. Couldn't find anything about this in their docs. I can see that they provide this functionality with Stream Chat
PS: We are able to get the notifications in the app but we would like to show the notification in the top tray as well so that the user knows he/she has received notifications without opening the app.
Regards,
Varun
I believe your question is about offering Push Notifications for your application. Stream Feeds does not currently implement Push Notifications out of the box so you will have to implement them in your application yourself. One common approach is to use notification webhooks where you have the webhook trigger a push notification for the user from your application's back end infrastructure.
I hope that is helpful.
Best,
Grant

Using the Bot Framework to post to a Microsoft Teams channel with NodeJS

Is there a way to send proactive cards from a bot to a Teams channel? The use case is a channel for service tickets. Once they get posted, a user will be able to interact with them with a few actions.
I’m looking at the documentation here for sending proactive messages. At the bottom, there’s a section for ”Creating channel conversations”, with a small reference to the startReplyChain(). However, the actual code and sample on GitHub still seem to reference a conversation with a member rather than sending something proactive to a channel.
There does appear to be documentation for incoming and outgoing webhooks, which is what I may end up doing. My only real concern is that it requires using Actionable Cards, which it references as legacy everywhere. This is despite saying that you can’t send Adaptive Cards with them. Perhaps they intend to enable these connectors to send Adaptive Cards, it’s not just very clear to me if this is a long-term solution I should be focusing on.
This is definitely possible, and it's important to note that you can even send from another process/application (e.g. on a schedule from an AWS Lamba). You can see a sample here for this.
The process of sending the message is just part of the story though - you need to have certain information already saved (e.g. in your database) to know how to contact the right user, group chat, or channel conversation, but there are a few ways to get that information. The most common is, when you bot is added to the conversation, to get it from the conversationUpdate event. You'll need conversation id, service url, tenant id, and your bot's App Id (what you get in the Azure portal for your bot, and which you're using already in your app's configuration, teams manifest, etc.). You can read more about the topic here and here.
Another option, if you don't have access to conversationUpdate (e.g. the user hasn't installed your app) is to call the Graph API to install your app. It's only possible to do this to a channel (on the v1 or beta api) (see here) or to a user (see here), but on the beta api only, and not (yet?) for a group chat.

Azure Notification Hub - do installations prevent duplicate notifications?

In the article describing the registration management it states that:
The following are some key advantages to using installations:
Creating or updating an installation is fully idempotent. So you can
retry it without any concerns about duplicate registrations
What does it exactly mean? I assume it doesn't mean the installations have a 'CreateOrUpdate' unlike registrations, because a similar method also exists there - 'CreateOrUpdateRegistrationAsync'.
Suppose that I've created two installations with different installation ID but the same PNS handle (pushChannel property) and identical tag 'foo' present in both installations. I'm going to send a notification using the SendTemplateNotificationAsync method using the 'foo' tag to select the target of my notification.
It's going to match both my installations, because they both contain the tag 'foo' and both have the same PNS handle. Is the device going to receive two notifications, or is Azure going to prevent delivery of duplicates in this case?
In the the same article I've linked the code samples do check for existing registrations with the PNS handle that's about to get registered:
// make sure there are no existing registrations for this push handle (used for iOS and Android)
string newRegistrationId = null;
var registrations = await hub.GetRegistrationsByChannelAsync(pushChannel.Uri, 100);
but they don't check that in the installations samples, which again suggests that Azure prevents delivery of duplicate notifications.
Creating or updating an installation is fully idempotent. So you can
retry it without any concerns about duplicate registrations
Here, an installation is a term used to describe an enhanced registration (with Azure's Notification Hub) to associate PNS of the device with tag(s) and/or template(s). "Idempotency" here is used with regards to the act of such an installation.
What it means is that you can simply call the same code for this type of registration every time your app starts or is brought to foreground without worrying about handling changes in PNS or previous states of registration with the Notification Hub.
This is good because the classic registration model can lead to duplicate registrations for the same device and user in the notification hub. Installation model doesn't do that.
Q. What would happen when you have one PNS assigned to multiple registrations with same tag in the Notification Hub and you try to push a notification by targeting a tag?
A. Azure Notification Hub has de-duplication logic which will prevent duplicate notifications from going out.
Q. Can you force multiple notifications (for the same tag) in any way if you have multiple applications but one Notification Hub?
A. You can if you can get multiple device tokens. However, in case of iOS, as APNS issues only one valid device token at a time, it will not be possible. Also, iOS apps have their own bundle identifier and therefore their own specific push certificate. And, Notification Hubs don't support multiple certificates. But in case of Android, you can force it if you use registration model and use older GCM registration Ids as they are renewed frequently and don't expire so easily.
Hope that helps! Cheers!

Azure Notification Hub and sending pushes to individual users?

I recently migrated an old push notification app to a new Azure Mobile Service. The MPNS API, apparently, has changed. It also automatically created a notification hub. Now instead of being able to define a clear channel URI for the message to be sent to, I need to specify a tag. I find it very hard to find information on this and how to send messages to individual users from Azure Mobile Services.
How is this done now?
Its actually pretty simple. Use your unique user identifier as a tag when you register.
Here is an example.
Registration reg = new AppleRegistration(token)
reg.getTags().add(userId)
hub.createRegistration(reg)
Now when you want to send to that user, send via the tag.
hub.sendNotification(Notification.createAppleNotification(payload), userId)
With Notification Hubs you have a few different options. Tags are the way of identifying who you want to push to (i.e. when you push to tag X, any device that has registered with tag X will be pushed to). So if you want to push based off of channel URI, when you register from the device, you should use the Channel URI as one of the tags. If you want to be able to push to all of a single user's devices, you'd need a different mechanism of knowing who the user is (i.e. registering with the username as a tag and then pushing to the username).

Does Azure Push Notification support a user Id or alias?

I am evaluating which Push Notification service to use out of Azure Mobile Services, Parse and Urban Airship.
One of the criteria is whether the service provides a way for the app to register a bespoke user Id or alias that can then easily be used when calling the service to send a push notification to an individual. This removes the need for our backend service to have a lookup table giving us the service registration ID for a given user.
Urban Airship has the alias feature: http://docs.urbanairship.com/connect/connect_audience.html#aliases
Parse has a sophisticated Installation object which behaves like a dictionary so that additional values can be added to it (like UserId). When the Parse service is called to send a Push Notification a query can be used to specify the user that will receive the message:
https://www.parse.com/docs/push_guide#sending-queries/REST
Is there an equivalent feature in Azure Mobile Services?
With Mobile Services, you would need to keep track of a user to token / channel URI / registration ID association in a table which is more work than you NEED to do. However, another feature of Windows Azure is Notification Hubs which does what you want (and much more). With Notification Hubs, from the client you say "I want to register for Notification Hubs, here are some tags you can use to push me information". Those tags can be anything you want including a User ID. Later on you can tell your Notification Hub to push to anyone registered with a certain tag. That would allow you to then push notifications out to any devices a specific user has registered.
The flow would look something like this:
Register with Push Provider (APNS, GCM, MPNS, WNS)
Send token to Notification Hubs along with tags (such as the User's ID)
Trigger a push to a specific Tag (i.e. User ID)
Notification Hubs will handle delivering a push to all devices with a Tag (again, their user ID)
Notification Hubs has client SDKs for WinPhone, WinStore, iOS, and Android so it's very easy to use from the client side. As far as triggering pushes goes, Notification Hubs exposes a REST API you can communicate with, there is a .NET SDK, a Node SDK, as well as an unofficial Java SDK. You can even use the Node SDK from Mobile Services which makes it super easy to combine authentication (i.e. getting User IDs) with data storage and push notifications. It also has lots of other features like templated push notifications so instead of specifying a different payload depending on what the device OS you're pushing to is, you can have the client application indicate how it should receive a certain type of push.

Resources