我正在尝试构建Outlook插件,我在Outlook在线(网络)上测试它,但是,“ Office.context.ui.messageParent ”无法与主机对话 .
在主机页面中,它运行下面的代码供用户登录(我使用AzureAD SSO登录用户)
var fullUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + "/AzureAD/Login";
Office.context.ui.displayDialogAsync(fullUrl, { height: 60, width: 60, }, function (result) {
var dialog = result.value;
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, processMessage);
});
function processMessage(arg) {
var resp = JSON.parse(arg.message);
console.log("Message received: " + JSON.stringify(resp));
}
它正确显示具有AzureAD权限的对话框,用户同意,之后,此对话框假设使用下面的代码(在对话框中)与主机对话:
Office.initialize = function (reason) {
$(document).ready(function () {
Office.context.ui.messageParent(true);
});
};
但是,主机无法在 processMessage 函数中获取任何消息 .
但是,相同的代码适用于Word Online的Word加载项 .
我还检查了DialogAPI doc,https://docs.microsoft.com/javascript/api/office/office.ui?product=outlook&view=office-js#displaydialogasync-startaddress--options--callback-
它提到:“ This method is available in the DialogApi requirement set for Word, Excel, or PowerPoint add-ins, and in the Mailbox requirement set 1.4 for Outlook ” .
我确实在我的清单文件中放了1.6 .
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.6" />
</Sets>
</Requirements>
仍然没有运气,任何想法?
谢谢