Reputation: 11
On token Refresh generate the Refresh token and store in database when the application is Installed.
Token Generated Code:
[Service]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class MyFirebaseIIDService : FirebaseInstanceIdService
{
const string TAG = "MyFirebaseIIDService";
//string refreshedToken;
private HttpClient client = new HttpClient();
public override void OnTokenRefresh()
{
var refreshedToken = FirebaseInstanceId.Instance.Token;
Log.Debug(TAG, "Refreshed token: " + refreshedToken);
SendRegistrationToServer(refreshedToken);
}}
Upvotes: 1
Views: 1010
Reputation: 2168
You could use the SqlConnection
Class in SendRegistrationToServer()
method to connect to your sql server.
For example:
void SendRegistrationToServer(string token)
{
using (SqlConnection connection = new SqlConnection(yourconnectionString))
{
SqlCommand command = new SqlCommand("INSERT INTO table1 (id, token) VALUES('1', '" + token + "')", connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
Upvotes: 1