Ejemplo n.º 1
0
        private Task <ServiceResponse> UpdateDeviceRegistration(string deviceId, string handle)
        {
            var subscribeToPushRequest = new PushSubscribeDetails
            {
                PushPlatformType = PlatformType,
                DeviceId         = deviceId,
                PushHandle       = ParsePushHandle(handle),
                TagsToRegisterIn = _pushTagsProvider.ActivePushTags
            };

            return(_remotePushRegistrationService.UpdateDeviceRegistration(subscribeToPushRequest));
        }
        public async Task <ServiceResponse> UpdateDeviceRegistration(PushSubscribeDetails subscribeDetails)
        {
            PlatformType platformType;

            switch (subscribeDetails.PushPlatformType)
            {
            case PushPlatformType.Android:
                platformType = PlatformType.GCM;
                break;

            case PushPlatformType.iOS:
                platformType = PlatformType.APNS;
                break;

            case PushPlatformType.Windows:
                platformType = PlatformType.WNS;
                break;

            default:
                throw new InvalidOperationException("Can't recognize platform type.");
            }

            var updateDeviceRegistrationResponse = await _restService.Execute <IPushNotificationsApi>(api =>
                                                                                                      api.UpdateSubscription(new UpdatePushSubscriptionRequest()
            {
                Handle   = subscribeDetails.PushHandle,
                Id       = subscribeDetails.DeviceId,
                Platform = platformType,
                Tags     = new List <string>()
                {
                    "new_tickets", "chat_message_added"
                }
            }, CancellationToken.None));

            return(updateDeviceRegistrationResponse.ToServiceResponse());
        }