Как отправить регистрационный токен на сервер приложений - PullRequest
0 голосов
/ 26 мая 2019

Как мне отправить регистрационный токен на сервер приложений, чтобы иметь возможность получать уведомления

Вот метод:

  void SendRegistrationToAppServer(string token)
    {
        //Add custom implementation here as needed.
        Settings.gcmKey = token;
    }

Я пытался добавить ключ GCM в токен api

  public async Task<string> LoginAysnc(string username, string password)
    {
        var results = await CrossGeolocator.Current.GetPositionAsync(TimeSpan.FromSeconds(10));
        decimal latitude = Convert.ToDecimal(results.Latitude);
        decimal longitude = Convert.ToDecimal(results.Longitude);
        string SIMCard = Settings.serialNum;
        string IMEICode = Settings.IMNum;

        var KeyValues = new List<KeyValuePair<string, string>>
        {
            new KeyValuePair<string, string>("username", username),
            new KeyValuePair<string, string>("password", password),
            new KeyValuePair<string, string>("grant_type", "password"),
            new KeyValuePair<string, string>("client_Id", "f0fc04db181f4d53b1560851ebf3b23d"),
            new KeyValuePair<string, string>("isappuser", true.ToString().ToLower()),
            new KeyValuePair<string, string>("SerialSIMCard", SIMCard),
            new KeyValuePair<string, string>("IMEICode", IMEICode),
            new KeyValuePair<string, string>("Latitude", latitude.ToString()),
            new KeyValuePair<string, string>("Longitude", longitude.ToString()),
            new KeyValuePair<string, string>("GCMKey", Settings.gcmKey)
        };

        try
        {
            var request = new HttpRequestMessage(HttpMethod.Post, "http://tracker-magconsulting.azurewebsites.net/Token");
            request.Content = new FormUrlEncodedContent(KeyValues);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Clear();
            var response = await client.SendAsync(request);
            var jwt = await response.Content.ReadAsStringAsync();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...