Azure notification hub [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a project with azure notification hub using my student Microsoft account. I start Microsoft free account and create another hub and using the same APNS certification from the first project. Now I can receive notification when I send test message from azure portal but I can't receive any message when I send it from my app. Using the same app just change the connections string and hub name?

Using the same app just change the connections string and hub name?
Normally, we will not send the notification directly from the client app. We usually send the notification from the server backend. About how to send the notification from backend you could refer to this article.
If you still want to send the notification by codes from your app, you could refer to this article.
In this article, provide three way to send the notification.
Using C# codes, node.js, rest api. You could choose one way to achieve your requirement.
Here is C# codes demo.
1.Install Microsoft.Azure.NotificationHubs from Nuget package.
2.Use below codes to send the notification.
private static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("<connection string with full access>", "<hub name>");
var alert = "{\"aps\":{\"alert\":\"Hello from .NET!\"}}";
await hub.SendAppleNativeNotificationAsync(alert);
}
Update:
I suggest you could check your connection string make sure the connection has the permission to send the notification.
Like this:
Then you could add this connection to the codes and set the right notification hub name in it.

Related

How to send messages with Firebase admin SDK [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Nuget used:
FireBaseAdmin v1.9.2
I'm trying to use firebase admin to send push notification to fcm.
I read the documentation but can't find any other good source to figure out how to use it properly.
I can't figure out where to add the serverkey and senderid.
I made a methode for sending push notifications.
Has anyone an example i could follow or any other documentation?
public override async Task<string> Send(List<String> tokens, string title, string body)
{
var message = Message()
{
Tokens = tokens,
Notification = new Notification()
{
Title = title,
Body = body
}
};
return await FirebaseMessaging.DefaultInstance.SendAsync(message).ConfigureAwait(false);
}
When i debug this code the response is null from SendAsync.
It might be because i didn't give it the serverkey and senderId but then i would expect an error like serverKeyNotFound.
Server key and sender ID parameters are not used in the Admin SDK. You just need to instantiate a FirebaseApp with some GoogleCredential as shown in https://firebase.google.com/docs/admin/setup.
On top of that your code seems to be syntactically incorrect. There's no Tokens property available in the Message class. You need MulticastMessage class for that. So I'd expect the above code to fail compilation.

Sending push notification to specific user using Facebook sid- Xamarin.Forms [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I build Xamarin.Forms App using this tutorial:
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started
and I choose .NET back end.
I implement push notification for android and ios using this:
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push
and also implement authentication using this: https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-users
while choosing Facebook as my authentication provider.
My app is running and working great! but now I trying to add push notification to a specific user and I have few questions:
Is it possible to use the Facebook sid as the unique id and decide that if I want to send push to a specific user, I will do this using the Facebook sid?
I read that when the user does the authentication through Facebook, his Facebook sid is register automatically has a unique id and I can send to this Facebook id as a TAG and it will arrived to the specific user.
In this line of code: var result = await hub.SendTemplateNotificationAsync(templateParams);
that is located in my .NET back end code in the " public async Task PostTodoItem(TodoItem item) " method, I tried to add a TAG after the "templateParams" , I tried to enter the Facebook sid or the Installation id, is this correct?
If I want to send to a specific user, is that the place that I need to add his "TAG"?
Am I going the right way? can I choose the TAG to be the unique id and when I want to send push to a specific user, I will send to his TAG?
I Wanted to know how the user is register to a specific TAG? if the approach from the second question is correct.
*If you have a written code or different approach, I would really like to hear, I trying to implement the push to specific user for about 2 weeks and still did not succeed.

Auto testing for Microsoft Bot Framework [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm working now on my first bot with Microsoft Bot Framework, with ASP.NET.
After manually testing with the bot emulator, I'm looking for the best method to create automatic testing for the bot.
Considering two problems:
What is the best tool to automate such tests?
What is the best method to test a dialog that can return different answers to the same input?
One alternative is doing functional tests using DirectLine. The caveat is that the bot needs to be hosted but it's powerfull. Check out the AzureBot tests project to see how this works.
Another alternative, is doing what the BotFramework team is doing for some of their unit tests.
If you are using Dialogs, you can take a look to the EchoBot unit tests as they are simple to follow.
If you are using Chain, then take a look to how their are using the AssertScriptAsync method.
https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/ChainTests.cs#L360
https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/ChainTests.cs#L538
If you are looking for a way to mock up Luis Service, see this.
You may want to consider Selenium. Selenium is web browser automation software allowing you to write tests that programmatically read and write to the DOM of a web page. With a Selenium script you can:
login on any channel that provides a web client (and most of them do: WebChat, Telegram, Skype, Facebook, for example)
start a conversation with your bot
perform operations such as post a message to the chat and wait for a reply
test whether the reply is what you expected.
For automated testing of bots in Node.js, using ConsoleConnector in the same way as the tests in BotBuilder on GitHub works well, e.g. take a look at https://github.com/Microsoft/BotBuilder/blob/master/Node/core/tests/localization.js:
var assert = require('assert');
var builder = require('../');
describe('localization', function() {
this.timeout(5000);
it('should return localized prompt when found', function (done) {
var connector = new builder.ConsoleConnector();
var bot = new builder.UniversalBot(connector);
bot.dialog('/', function (session, args) {
session.send('id1');
});
bot.on('send', function (message) {
assert(message.text === 'index-en1');
done();
});
connector.processMessage('test');
});
...etc...

How to Monitor HTTP Requests Directly From C# Server Console? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
does anyone know how to get a C# server application running in the console to display HTTP requests from a client as shown in this image?
http://imgur.com/filhZJZ
Thanks in advance!
If all you want to do is spin up an HTTP server and write out requests to the console, it should be pretty easy to accomplish using OWIN and Katana. Just install the following NuGet packages:
Microsoft.Owin.Hosting
Microsoft.Owin.Host.HttpListener
And use something along the lines of the following:
public static class Program
{
private const string Url = "http://localhost:8080/";
public static void Main()
{
using (WebApp.Start(Url, ConfigureApplication))
{
Console.WriteLine("Listening at {0}", Url);
Console.ReadLine();
}
}
private static void ConfigureApplication(IAppBuilder app)
{
app.Use((ctx, next) =>
{
Console.WriteLine(
"Request \"{0}\" from: {1}:{2}",
ctx.Request.Path,
ctx.Request.RemoteIpAddress,
ctx.Request.RemotePort);
return next();
});
}
}
You can of course tweak the output to your liking, having access to the full request and respose objects.
It will give you something like this:
You can do this using System.Diagnostics Tracing in Web API. On the asp.net website, you'll be able to read a detailed article.
Another possibility is turning on the IIS logging and then read the logfiles. I'm not quite sure how this is done, it's just what I do on apache2/linux, where you can tail -f log. I read something about powershell equivalents, but not for consoleapps, so I think I would stick with the Tracing.
Edit: After some looking around on SO I found this similar question with relevant answers:
How do I see the raw HTTP request that the HttpWebRequest class sends?

Is there a google voice api for sending text messages? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Does anyone know of any working gvoice api? I have found this project:
http://sourceforge.net/projects/gvoicedotnet/
but the login appears to no longer work since the url changed some months ago.
Does anyone have a good question for sending out text messages to users of my website?
I found one: SharpGoogleVoice.
https://bitbucket.org/jitbit/sharpgooglevoice/downloads
It only has text messaging support, but it works well and looks like good work.
Self-promotion: my API, SharpVoice, works/worked quite well (hasn't been tested in some time): https://github.com/descention/sharp-voice
Voice voiceConnection = new Voice(loginEmail, loginPassword);
string response = voiceConnection.SendSMS(smsToPhoneNumber, smsMsgBody);
What you need is an SMS gateway that will let you send out text messages via an API. A quick Google search yields Zeep Mobile, which lets developers send SMS text messages for free from their application.
Because it's free, there may very well be some restrictions, but if you architect your app correctly using a strategy or adapter pattern then you should be able to replace this module later on down the road with something more advanced based on the needs of your application.
The primary restriction on the free plan is that it's ad-supported. This may very well be ok for you during initial development and testing, but your production users will likely find this to be a significant problem in using your service. Zeep does have a paid plan that eliminates the ads, and there are of course countless other SMS gateways that have API's that you can use for a fee.
You can get send messages with Twilio.
An example using the C# helper library:
https://www.twilio.com/docs/libraries/csharp
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/user/account
string AccountSid = "YOUR_ACCOUNT_SID";
string AuthToken = "YOUR_AUTH_TOKEN";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var message = twilio.SendMessage(
"+15017250604", "+15558675309",
"Hey Kyle! Glad you asked this question.",
new string[] { "http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg" }
);
Console.WriteLine(message.Sid);
}
}

Categories