Exemplo n.º 1
0
        public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
                                                          string identifier, DeviceType type)
        {
            var tokenStateResponse = await HandleTokenStateAsync();

            if (!tokenStateResponse)
            {
                return;
            }

            var requestModel = new PushRegistrationRequestModel
            {
                DeviceId   = deviceId,
                Identifier = identifier,
                PushToken  = pushToken,
                Type       = type,
                UserId     = userId
            };

            var message = new TokenHttpRequestMessage(requestModel, AccessToken)
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/register"))
            };

            try
            {
                await PushClient.SendAsync(message);
            }
            catch (Exception e)
            {
                _logger.LogError(12335, e, "Unable to create push registration.");
            }
        }
Exemplo n.º 2
0
        public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
                                                          string identifier, DeviceType type)
        {
            var requestModel = new PushRegistrationRequestModel
            {
                DeviceId   = deviceId,
                Identifier = identifier,
                PushToken  = pushToken,
                Type       = type,
                UserId     = userId
            };

            await SendAsync(HttpMethod.Post, "push/register", requestModel);
        }
Exemplo n.º 3
0
 public async Task PostRegister([FromBody] PushRegistrationRequestModel model)
 {
     CheckUsage();
     await _pushRegistrationService.CreateOrUpdateRegistrationAsync(model.PushToken, Prefix(model.DeviceId),
                                                                    Prefix(model.UserId), Prefix(model.Identifier), model.Type);
 }