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

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.

Related

Invitation link implementation .NET WEB API [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 2 days ago.
Improve this question
I`m developing .NET Web API pet application, that uses JWT authentication.
It has private rooms(lets say lobbies), so users don't have access to the list of them.
The idea is to create invitation link like https://mycoolapp.com/Room/sd1Fds/join=token,
so unauthorized user can click it and join room after he logs in.
The idea comes from discord invitation link
Like here
I want it to have expiration time, so user can choose between 3,5,7 hours for example.
Discord implementation
The question is, how should I implement it, Im currently looking at SecurityToken` class, is that right approach?
yes, the SecurityToken is a good point to start
you can create a room and generate a unique id (GUID) for that. then create a JWT token and include the generated unique id as a claim into it. then generate the invitation link including the JWT token and send it to guest
after the guest clicks on the link, redirect to the login page and then redirect to the API with the JWT token included in the query string. in the endpoint that handles the invitation link, check if everything is ok and the id exists as a claim, and the expiration time is ok, grant the user access to the private room
Personally I would go with KISS principle and just generated some random unique id (Guid.NewGuid can be sufficient) and stored it in the database with additional information (like expiration date, invited person ids, etc.) and on join attempt validated that link against the stored data (link has not expired, person attempting to join is in the list, etc.).

Azure notification hub [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 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.

How to turn wireless radio on/off in Windows? [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 6 years ago.
Improve this question
I'm looking for an API to programmatically toggle a wireless radio on and off in Windows, just like the following Windows 10 UI element does:
Need to toggle on/off Wi-Fi, Bluetooth, or mobile broadband
For Windows 7, 8 and 10
This is NOT a phone
C#/.NET4.5 would be ideal, but C++/Win32 would work too
For Windows 10, you can use the Radio Manager APIs to control different radio states. You can find the full sample apps here (both C# and C++).
First you need to get access to all of the system radios. This must be called in a UI thread:
var accessLevel = await Radio.RequestAccessAsync();
Then, you can find all radios on the system (the sample describes other ways to access the radios):
var radios = await Radio.GetRadiosAsync();
Given a radio object, you can then change state by the following:
Radio radio = SOME_RADIO;
radio.StateChanged = Radio_StateChangedCallback; // Called when the radio state completes the change
radio.SetStateAsync(RadioState.On); // Or RadioState.Off
So in general what you need to do is to enumerate the network adapters (filter out Wireless, Bluetooth and Mobile Broadband) and toggle their state?
No wonders that there are 3 close votes since SO is full of related questions and answers:
This demonstrates C# + WMI
This demonstrates C++ + WINAPI Device Installation API
One of those should be a fair starting point to put together what you need.
Well I know you can manipulate the wireless connection with
netsh interface set interface name="Local Area Connection" via cmd line.
So maybe in c# you could do a Process.Start("netsh", "set name=\"Local Area Connection\""); to change the wifi settings. I'm sure you could download a bluetooth cmd line utility and do something similar with that.
I'll be able to test later when I get on my windows machine, but I can't right now, hopefully this helps.

Time Based Login [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 8 years ago.
Improve this question
In my .NET web application I need to implement time based Logins for students,The system should allow students to login only between 9 AM and 5 PM. somebody please suggest me how to implement this, which is better implementing using SQL time functions or using .net time methods?
If simply compare using normal time functions will it create when I host the application on a remote server(out side My country)?
Assuming that there are some users who are not students: (1) authenticate the user, (2) check the user's roles and if they are a student and attempting a login at naughty time then logout the user and display an appropriate message.
Using a single source for time in an application can reduce complications. I often use the database server as the source of time so that all timestamped data generated by the application can be correlated properly. UTC can be your friend in this case.
You can handle loggingIn event of login control and check if DateTime.Now lays between 9AM and 5PM
void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
{
DateTime loginTime=DateTime.Now;
if (loginTime.Hour >= 9 && loginTime.Hour <= 17)
//log in your user
else
//show error message about time
}

What's the most professional way for login control in ASP.NET? [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 8 years ago.
Improve this question
Say, we are not using forms authentication or membership. When a user requests for any of the pages of the application, she needs to be redirected to login page.
This way, each page needs to have an authentication check on the Page_Load(). But what if we have over 500 pages.
Any chance to use sth like static classes with static properties or creating your own http handlers?
This is too broad of a question with a few aspects, including :
How to manage a User's Session
How to manage multiple user accounts being logged in
How to perform the login process
Managing a user's state must be independent of anyone else's actions. Therefor, you cannot rely on static properties. This presents the question of "Well, how do I keep track of it without it being static?" One of the answers is to use Session information. For example, during an Ajax request to the server you could do this :
if (HttpContext.Current.Session["LoggedIn"] != null)
{
object oValue = HttpContext.Current.Session["LoggedIn"];
bool bResult;
if (bool.TryParse((string)oValue, out bResult) == true)
return bResult
return false;
}
else
return false;
This solves the first two issues and opens a door to creating a hanlder class that knows YOUR specific session keys and patterns for getting different kinds of values.
As for the third issue you will face - No one can give you a concrete answer. Your design and data structure will determine how you validate and track your users.

Categories