Universal Windows Platform App with google calendar

我是研究僧i 提交于 2019-12-24 04:09:16

问题


Hey im trying to make an Universal Windows Platform App where google calendar is in it, but i cant figure out how to convert the code, i got the code to work on a WPF App. I am not the best at coding https://developers.google.com/google-apps/calendar/quickstart/dotnet this is the site i use as a guideline in the start if its to any help, any help? Code below:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;

namespace Test1UWA
{
    class GoogleEvents4
    {
        public string Title { get; set; }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; }
    }

    class GoogleClass4
    {
        public List<GoogleEvents4> GoogleEvents = new List<GoogleEvents4>();

        static string[] Scopes = { CalendarService.Scope.CalendarReadonly };
        static string ApplicationName = "Google Calendar API .NET Quickstart";



        public GoogleClass4()
        {
            UserCredential credential;

            using (var stream =
                            new FileStream("client_secret4.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;

            }
            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });

            // Define parameters of request.
            EventsResource.ListRequest request = service.Events.List("primary");
            request.TimeMin = DateTime.Now;
            request.ShowDeleted = true;
            request.SingleEvents = true;
            request.MaxResults = 10;
            request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;

            // List events.
            Events events = request.Execute();
            if (events.Items != null && events.Items.Count > 0)
            {
                foreach (var eventItem in events.Items)
                {
                    string when = eventItem.Start.DateTime.ToString();
                    if (String.IsNullOrEmpty(when))
                    {
                        when = eventItem.Start.Date;
                    }

                    GoogleEvents.Add(new GoogleEvents4 { Title = eventItem.Summary, StartDate = eventItem.Start.DateTime, EndDate = eventItem.End.DateTime });


                }
            }
        }
    }
}

回答1:


At this time the Google .net Client library does not support UWP.

Link from the client library (supported platform list)

chrisdunelm 27 days ago Google member Unfortunately we don't support UWP yet, so it can't be on the list yet. Maybe we should highlight that we don't support it :(

Update:

We plan to support UWP in the v2.0 release, which we hope will be early 2017.



来源:https://stackoverflow.com/questions/40522651/universal-windows-platform-app-with-google-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!