Beispiel #1
0
        public async Task <bool> Register(PushUri pushUri)
        {
            if (pushUri == null || String.IsNullOrWhiteSpace(pushUri.DeviceId))
            {
                return(false);
            }

            string deviceId = pushUri.DeviceId.GetHashCode().ToString();

            // We just store the full Device Id in the PushUri object, the hashed version is for Azure
            //var existingPushUri = _pushUriService.GetPushUriByPlatformDeviceId((Platforms)pushUri.PlatformType, pushUri.DeviceId);
            List <PushRegistrationDescription> usersDevices = null;

            try
            {
                usersDevices = await _notificationProvider.GetRegistrationsByUserId(pushUri.UserId);
            }
            catch (TimeoutException)
            { }


            //if (existingPushUri == null)
            //	pushUri = _pushUriService.SavePushUri(pushUri);

            if (usersDevices == null || !usersDevices.Any(x => x.Tags.Contains(deviceId)))
            {
                await _notificationProvider.RegisterPush(pushUri);
            }

            return(true);
        }