protected override Installation CreateInstallation(PushConfig pushConfig) { string operatingSystem = Environment.OSVersion.Platform.ToString(); string osVersion = Environment.OSVersion.Version.ToString(); Installation installation = new Installation() { alias = pushConfig.Alias, operatingSystem = operatingSystem, osVersion = osVersion, categories = pushConfig.Categories }; return installation; }
protected override Installation CreateInstallation(PushConfig pushConfig) { _config = (AndroidPushConfig) pushConfig; return _installation = new Installation { alias = pushConfig.Alias, categories = pushConfig.Categories, operatingSystem = "android", osVersion = Build.VERSION.Release }; }
public async Task<HttpStatusCode> Register(Installation installation) { var request = CreateRequest(uri.ToString() + REGISTRATION_ENDPOINT); request.Method = "POST"; using (var postStream = await Task<Stream>.Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, request)) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Installation)); serializer.WriteObject(postStream, installation); } return await ReadResponse(request); }
protected override Installation CreateInstallation(PushConfig pushConfig) { var deviceInformation = new EasClientDeviceInformation(); var os = deviceInformation.OperatingSystem; var deviceType = deviceInformation.SystemProductName; var installation = new Installation { alias = pushConfig.Alias, operatingSystem = os, osVersion = deviceType, categories = pushConfig.Categories }; return installation; }
protected override Installation CreateInstallation(PushConfig pushConfig) { var deviceInformation = new EasClientDeviceInformation(); var os = deviceInformation.OperatingSystem; var deviceType = deviceInformation.SystemProductName; var installation = new Installation { alias = pushConfig.Alias, operatingSystem = os, osVersion = deviceType, categories = pushConfig.Categories }; return(installation); }
public async Task <string> Register(PushConfig pushConfig, IUPSHttpClient client) { Installation installation = CreateInstallation(pushConfig); ILocalStore store = CreateChannelStore(); string channelUri = await ChannelUri(); var token = pushConfig.VariantId + channelUri; if (!token.Equals(store.Read(CHANNEL_KEY))) { installation.deviceToken = channelUri; await client.Register(installation); store.Save(CHANNEL_KEY, token); } return(installation.deviceToken); }
public async Task <HttpStatusCode> Register(Installation installation) { var request = CreateRequest(Uri + RegistrationEndpoint); request.Method = "POST"; using ( var postStream = await Task <Stream> .Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, request)) { var serializer = new DataContractJsonSerializer(typeof(Installation)); serializer.WriteObject(postStream, installation); } return(await ReadResponse(request)); }
public async Task <HttpStatusCode> register(Installation installation) { using (var postStream = await Task <Stream> .Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, request)) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Installation)); serializer.WriteObject(postStream, installation); } HttpWebResponse responseObject = (HttpWebResponse)await Task <WebResponse> .Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, request); var responseStream = responseObject.GetResponseStream(); var streamReader = new StreamReader(responseStream); await streamReader.ReadToEndAsync(); return(responseObject.StatusCode); }
protected async override Task <string> Register(Installation installation, IUPSHttpClient client) { this.installation = installation; this.client = client; HttpNotificationChannel channel; string channelName = "ToastChannel"; channel = HttpNotificationChannel.Find(channelName); if (channel == null) { channel = new HttpNotificationChannel(channelName); } var tcs = new TaskCompletionSource <string>(); channel.ChannelUriUpdated += async(s, e) => { ChannelStore channelStore = new ChannelStore(); if (!e.ChannelUri.ToString().Equals(channelStore.Read())) { installation.deviceToken = e.ChannelUri.ToString(); await client.register(installation); channelStore.Save(installation.deviceToken); tcs.TrySetResult(installation.deviceToken); } }; channel.ErrorOccurred += (s, e) => { tcs.TrySetException(new Exception(e.Message)); }; channel.ShellToastNotificationReceived += new EventHandler <NotificationEventArgs>(PushChannel_ShellToastNotificationReceived); channel.Open(); channel.BindToShellToast(); return(await tcs.Task); }
public Task <HttpStatusCode> Register(Installation installation) { Installation = installation; return(Task.Run(() => HttpStatusCode.OK)); }
public Task<HttpStatusCode> Register(Installation installation) { Installation = installation; return Task.Run(() => HttpStatusCode.OK); }
protected abstract Task <string> Register(Installation installation, IUPSHttpClient iUPSHttpClient);
public async Task <string> Register(PushConfig pushConfig) { Installation installation = CreateInstallation(pushConfig); return(await Register(installation, CreateUPSHttpClient(pushConfig))); }