Exemple #1
0
        public async Task UpdateConfig(PushConfig pushConfig, IUPSHttpClient client)
        {
            var installation = CreateInstallation(pushConfig);

            installation.deviceToken = CreateChannelStore().Read(CHANNEL_KEY).Substring(pushConfig.VariantId.Length);
            await client.Register(installation);
        }
 public override async Task<string> Register(PushConfig pushConfig, IUPSHttpClient client)
 {
     Installation installation = CreateInstallation(pushConfig);
     ILocalStore store = CreateChannelStore();
     string channelUri = await ChannelUri();
     var token = pushConfig.VariantId + channelUri;
     installation.deviceToken = channelUri;
     await client.Register(installation);
     return installation.deviceToken;
 }
        public override async Task <string> Register(PushConfig pushConfig, IUPSHttpClient client)
        {
            Installation installation = CreateInstallation(pushConfig);
            ILocalStore  store        = CreateChannelStore();
            string       channelUri   = await ChannelUri();

            var token = pushConfig.VariantId + channelUri;

            installation.deviceToken = channelUri;
            await client.Register(installation);

            return(installation.deviceToken);
        }
        public async virtual 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;
        }
Exemple #5
0
        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);
        }
        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);
        }
Exemple #7
0
 public async Task <string> Register(IUPSHttpClient client)
 {
     return(await Register(await LoadConfigJson(FILE_NAME), client));
 }
 protected abstract Task <string> Register(Installation installation, IUPSHttpClient iUPSHttpClient);
 public async Task <string> Register(PushConfig pushConfig, IUPSHttpClient client)
 {
     return(await Register(CreateInstallation(pushConfig), client));
 }
 public async Task<string> Register(IUPSHttpClient client)
 {
     return await Register(await LoadConfigJson(FILE_NAME), client);
 }
 public async Task UpdateConfig(PushConfig pushConfig, IUPSHttpClient client)
 {
     var installation = CreateInstallation(pushConfig);
     installation.deviceToken = CreateChannelStore().Read(CHANNEL_KEY).Substring(pushConfig.VariantId.Length);
     await client.Register(installation);
 }