Как создать приложение с поддержкой нажатием в Windows Phone 8.1?

StackOverflow https://stackoverflow.com//questions/25015593

Вопрос

Я пытаюсь включить мое приложение, чтобы я мог использовать вкладку Уведомления о дополнительных инструментах Windows, связанных с эмулятором Windows Phone.

e.g.:

Введите описание изображения здесь

Я включил симуляцию и отменил приложение, но генеракодицетагкод, генеракодицетагкод и другие поля не заполняются.

Как я могу включить приложение для push-уведомлений, чтобы эти поля были заполнены?

Это было полезно?

Решение

Вам нужно зарегистрироваться для push-уведомлений.Когда у вас есть канал Push-уведомлений, вкладка «Уведомления» может затем получить URI Push-уведомления URI

    public IAsyncOperation<ChannelAndWebResponse> OpenChannelAndUploadAsync(String url)
    {
        IAsyncOperation<PushNotificationChannel> channelOperation = PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
        return ExecuteChannelOperation(channelOperation, url, MAIN_APP_TILE_KEY, true);
    }

    public IAsyncOperation<ChannelAndWebResponse> OpenChannelAndUploadAsync(String url, String inputItemId, bool isPrimaryTile)
    {
        IAsyncOperation<PushNotificationChannel> channelOperation;
        if (isPrimaryTile)
        {
            channelOperation = PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(inputItemId);
        }
        else
        {
            channelOperation = PushNotificationChannelManager.CreatePushNotificationChannelForSecondaryTileAsync(inputItemId);
        }

        return ExecuteChannelOperation(channelOperation, url, inputItemId, isPrimaryTile);
    }

    private IAsyncOperation<ChannelAndWebResponse> ExecuteChannelOperation(IAsyncOperation<PushNotificationChannel> channelOperation, String url, String itemId, bool isPrimaryTile)
    {
        return channelOperation.AsTask().ContinueWith<ChannelAndWebResponse>(
            (Task<PushNotificationChannel> channelTask) =>
            {
                PushNotificationChannel newChannel = channelTask.Result;
                String webResponse = "URI already uploaded";

                // Upload the channel URI if the client hasn't recorded sending the same uri to the server
                UrlData dataForItem = TryGetUrlData(itemId);

                if (dataForItem == null || newChannel.Uri != dataForItem.ChannelUri)
                {
                    HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
                    webRequest.Method = "POST";
                    webRequest.ContentType = "application/x-www-form-urlencoded";
                    byte[] channelUriInBytes = Encoding.UTF8.GetBytes("ChannelUri=" + WebUtility.UrlEncode(newChannel.Uri) + "&ItemId=" + WebUtility.UrlEncode(itemId));

                    Task<Stream> requestTask = webRequest.GetRequestStreamAsync();
                    using (Stream requestStream = requestTask.Result)
                    {
                        requestStream.Write(channelUriInBytes, 0, channelUriInBytes.Length);
                    }

                    Task<WebResponse> responseTask = webRequest.GetResponseAsync();
                    using (StreamReader requestReader = new StreamReader(responseTask.Result.GetResponseStream()))
                    {
                        webResponse = requestReader.ReadToEnd();
                    }
                }

                // Only update the data on the client if uploading the channel URI succeeds.
                // If it fails, you may considered setting another AC task, trying again, etc.
                // OpenChannelAndUploadAsync will throw an exception if upload fails

                //https://db3.notify.windows.com/?token=AgYAAABRl%2fdFlmxVkJPDROr5LRwp4tRW0Hcp006ODyaAkBppfiPDsAW%2fNRqsaIc0UFw3DMA15C%2btvGwtkreUZrBLs9vxOxCWL0fYw%2ft2HDFuTDM4szMxFWGom6B3kkGMiPa4C1o%3d

                UpdateUrl(url, newChannel.Uri, itemId, isPrimaryTile);
                return new ChannelAndWebResponse { Channel = newChannel, WebResponse = webResponse };
            }).AsAsyncOperation();
    }
.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top