简体   繁体   English

Xamarin.Android:从另一个应用程序打开日历中的特定事件

[英]Xamarin.Android: open specific event in calendar from another app

I'm currently working on an app in Xamarin.Android with one of the features being that, upon clicking a button, the user is taken to a specific calendar event in the Microsoft Outlook app.我目前正在 Xamarin.Android 中开发一个应用程序,其中一个功能是,单击按钮后,用户将被带到 Microsoft Outlook 应用程序中的特定日历事件。 Thus far I've been using the Microsoft Graph API to get the event items and I've succeeded in opening the Outlook app to the calendar or opening Outlook with an error message saying "Event could not be opened" but I haven't gotten both behaviors to happen, nor the specific event item to open.到目前为止,我一直在使用 Microsoft Graph API 来获取事件项,并且我已经成功地将 Outlook 应用程序打开到日历或打开 Outlook 并显示一条错误消息“无法打开事件”,但我还没有得到这两种行为都会发生,也不会打开特定的事件项目。 The way I open the Outlook app is by calling the device's default browser with an Outlook uri scheme.我打开 Outlook 应用程序的方式是使用 Outlook uri 方案调用设备的默认浏览器。 Both are provided below两者都在下面提供

browserLaunch("ms-outlook://events/open?account={my.account@email.com}&restid={id}");


private async void browserLaunch( string uri ) {
    await Browser.OpenAsync(uri, BrowserLaunchMode.SystemPreferred);
}

The exact call I've been making to the Graphs API is as follows我对 Graphs API 的确切调用如下

https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2020-01-23T15:54:40.377Z&enddatetime=2020-01-30T15:54:40.377Z

which returns a list of even items with the following scheme:它返回具有以下方案的偶数项列表:

        "@odata.etag": "string",
            "id": "string",
            "createdDateTime": "20##-##-##T##:##:##.######Z",
            "lastModifiedDateTime": "20##-##-##T#3:##:##.#######Z",
            "changeKey": "string",
            "categories": [],
            "originalStartTimeZone": "Central Standard Time",
            "originalEndTimeZone": "Central Standard Time",
            "iCalUId": "string",
            "reminderMinutesBeforeStart": int,
            "isReminderOn": true/false,
            "hasAttachments": true/false,
            "subject": "string",
            "bodyPreview": "string",
            "importance": "string",
            "sensitivity": "string",
            "isAllDay": true/false,
            "isCancelled": true/false,
            "isOrganizer": true/true,
            "responseRequested": true/false,
            "seriesMasterId": null,
            "showAs": "string",
            "type": "string",
            "webLink": "https://outlook.office365.com/owa/?itemid={id}&exvsurl={int}&path=/calendar/item",
            "onlineMeetingUrl": null,
            "recurrence": null,
            "responseStatus": {
                "response": "none",
                "time": "0001-01-01T00:00:00Z"
            },
            "body": {
                "contentType": "html",
                "content": "string"
            },
            "start": {
                "dateTime": "20##-##-##T##:##:##.#######",
                "timeZone": "UTC"
            },
            "end": {
                "dateTime": "20##-##-##T##:##:##.#######",
                "timeZone": "UTC"
            },
            "location": {
                "displayName": "string",
                "locationType": "string",
                "uniqueId": "string",
                "uniqueIdType": "stirng"
            },
            "locations": [
                {
                    "displayName": "string",
                    "locationType": "string",
                    "uniqueId": "hexstrin-hexs-hexs-hexs-hexstringhex",
                    "uniqueIdType": "string"
                }
            ],
            "attendees": [
                {
                    "type": "string",
                    "status": {
                        "response": "string",
                        "time": "0001-01-01T00:00:00Z"
                    },
                    "emailAddress": {
                        "name": "string",
                        "address": "my.account@email.com"
                    }
                }
            ],
            "organizer": {
                "emailAddress": {
                    "name": "string",
                    "address": "my.account@email.com"
                }
            }

I've also tried different ids that are given by the graphs API for the restid param.我还尝试了图形 API 为 restid 参数提供的不同 ID。 Thus far I've used the itemid param found in the url of the webLink field, the id of the json object, the changeKey, and the iCalUId but those last two didnt get me anything beyond just opening up Outlook.到目前为止,我已经使用了在 webLink 字段的 url 中找到的 itemid 参数、json 对象的 id、changeKey 和 iCalUId,但最后两个参数除了打开 Outlook 之外什么也没给我。

I've also just passed in the webLink but it just opens a lightweight browser (and get's stuck on a white page) which I don't want as I need it specifically to go to the Outlook app.我也刚刚传入了 webLink,但它只是打开了一个轻量级浏览器(并且卡在了白页上),我不想要它,因为我需要它专门用于访问 Outlook 应用程序。 Any ideas?有任何想法吗?

So the best current solution I have been able to find is to open up a lightweight browser using a different url scheme than any prior:因此,目前我能找到的最佳解决方案是使用与以往不同的 url 方案打开一个轻量级浏览器:

https://outlook.office365.com/calendar/item/{webLinkItemId}

where webLinkItemId is the itemId param from the webLink url gotten from the returned Graphs API json object.其中 webLinkItemId 是从返回的 Graphs API json 对象中获取的 webLink url 中的 itemId 参数。 You can find that complete object above in my original post but what you're looking for within that object is the following field您可以在我的原始帖子中找到上面的完整对象,但您在该对象中寻找的是以下字段

"webLink": "https://outlook.office365.com/owa/?itemid={webLinkItemId}&exvsurl={int}&path=/calendar/item"

You want to take the {webLinkItemId} string embedded in the url above and plug it into the corresponding spot in the scheme above你想把上面 url 中嵌入的 {webLinkItemId} 字符串插入上面方案中的相应位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM