public void Tags()
 {
     var service = new GetRegistrationService
                       {
                           RequestBuilder = ServerRequestBuilder.Instance
                       };
     var request = new GetRegistrationRequest
                                      {
                                          DeviceToken = "ApplePushId"
                                      };
     service.Execute(request, Callback, ExceptionHandler.Handle);
 }
        public void Execute(GetRegistrationRequest request, Action<GetRegistrationResponse> responseCallback, Action<Exception> exceptionCallback)
        {
            var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/device_tokens/" + request.DeviceToken);
            webRequest.Method = "Get";

            var asyncRequest = new AsyncRequest
            {
                ReadFromResponse = stream => responseCallback(GetRegistrationResponseDeSerializer.DeSerialize(stream)),
                Request = webRequest,
                ExceptionCallback = exceptionCallback,
                RequestContentType = "application/json"
            };

            asyncRequest.Execute();
        }
예제 #3
0
        public void Execute(GetRegistrationRequest request, Action <GetRegistrationResponse> responseCallback, Action <Exception> exceptionCallback)
        {
            var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/device_tokens/" + request.DeviceToken);

            webRequest.Method      = "Get";
            webRequest.ContentType = "application/json";

            var asyncRequest = new AsyncRequest
            {
                ReadFromResponse  = stream => responseCallback(GetRegistrationResponseDeSerializer.DeSerialize(stream)),
                Request           = webRequest,
                ExceptionCallback = exceptionCallback,
            };

            asyncRequest.Execute();
        }
        public void NotFound()
        {
            var service = new GetRegistrationService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };


            var helper = new AsyncTestHelper<GetRegistrationResponse>();
            var getRegistrationRequest = new GetRegistrationRequest
                                             {
                                                 DeviceToken = "foo"
                                             };
            service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException);
            helper.Wait();
            Assert.IsNull(helper.Response);
        }
        public void Simple()
        {
            var service = new GetRegistrationService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };


            var helper = new AsyncTestHelper<GetRegistrationResponse>();
            var getRegistrationRequest = new GetRegistrationRequest
                                             {
                                                 DeviceToken = RemoteSettings.AppleDeviceId
                                             };
            service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException);
            helper.Wait();

            var registration = helper.Response;
            Debug.WriteLine(registration.Alias);
            Debug.WriteLine(registration.Badge);
            Debug.WriteLine(registration.QuietTime.Start);
            Debug.WriteLine(registration.QuietTime.End);
            Debug.WriteLine(string.Join(" ", registration.Tags));
            Debug.WriteLine(registration.TimeZone);
        }