简体   繁体   English

如何使用深层链接将自定义查询参数传递给选项卡

[英]How to pass custom query parameters to the tab using deep link

In my team app, I defined a staticTab like:在我的团队应用程序中,我定义了一个 staticTab,例如:

"staticTabs": [
        {
            "entityId": "auth",
            "name": "auth",
            "contentUrl": "https://www.example.com/",
            "scopes": [
                "personal"
            ]
        }
    ],

I want to pass some custom query parameters to the content tab using deep link when sending notification to users in teams:在向团队中的用户发送通知时,我想使用深层链接将一些自定义查询参数传递到内容选项卡:

    entityWebUrl=f"https://www.example.com/?auth=username"
    deeplink=f"https://teams.microsoft.com/l/entity/{APP_ID}/{entityId}?webUrl={entityWebUrl}"

    payload = {
        "topic": {
            "source": "text",
            "value": "auth",
            "webUrl": deeplink
        },
...

In my app, I parse the params with:在我的应用程序中,我用以下方法解析参数:

const search = new URLSearchParams(window.location.search);
  const params = [];
  search.forEach((value, name) => {
    console.log(`${name}: ${value}`);
    params.push({ name: name, value: value });
  });

But it does not seem working.但它似乎不起作用。 The content tab does not get the username.内容选项卡不获取用户名。 Can anyone help what I am missing?谁能帮助我缺少什么? Thank you!谢谢!

You need to encode the webUrl while preparing the deeplink.您需要在准备深层链接时对 webUrl 进行编码。

Also, if you want to get the passed parameters, you can use like below:另外,如果你想获取传递的参数,你可以像下面这样使用:

const urlParams = new URLSearchParams(decodeURIComponent(window.location.search));

Reference code sample link: https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-token-app/nodejs/client/src/components/ContentBubble.js参考代码示例链接: https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-token-app/nodejs/client/src/components/ContentBubble.js

https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-token-app/csharp/ClientApp/public/contentBubble.html https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-token-app/csharp/ClientApp/public/contentBubble.html

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

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