2019年如何在Android原生应用中添加Power BI报表 [英] How to add Power BI reports in Android native app in 2019

查看:22
本文介绍了2019年如何在Android原生应用中添加Power BI报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Android 应用程序,我应该在其中显示 Power BI 报告和具有向下钻取功能的磁贴.

I am developing an Android application in which I should show Power BI reports and tiles with drill down.

我在 Google 上搜索过,但仍然找不到合适的文档.

I Googled but still I am not able to find a proper documentation for same.

我知道有一个 Rest API,但我找不到任何关于获取数据后发生的确切情况的文档.我已经看到其他示例/问题,他们在应用程序中嵌入了一个网络以显示仪表板,但我无法看到完整的示例/视频工作.

I understand that there is a Rest API, but I cant find any documentation on exactly what happens after getting the data. I have seen other example/questions where they embed a web inside the app to show a dashboard, but I havent been able to see a full example/video working.

请帮忙,提前谢谢.

推荐答案

这里有一个 工作示例 为您服务.它展示了如何在本机桌面应用程序中嵌入 Power BI 元素.对于 android,它基本上是相同的 - 它在您的应用程序的网络浏览器中加载.

Here is a working example for you. It shows how to embed Power BI elements in a native desktop application. For android it's basically the same - it loads in a web browser in your app.

首先你需要知道嵌入Power BI有两种模式——用户拥有数据app拥有数据.在第一种模式下,嵌入时,用户将使用自己的 Power BI Pro 帐户进行身份验证,即您的每个用户都需要 Power BI Pro 许可证.使用后一种,您只需要一个主帐户",它将用于身份验证.实现上的差异并不大,所以我将描述 app 拥有数据.

First you need to know that there are two modes for embedding Power BI - user owns data and app owns data. With the first mode, when embedding, the user will authenticate itself using it's own Power BI Pro account, i.e. each of your users needs Power BI Pro license. With the later one, you need only one "master account", which will be used for authentication. The differences in the implementation aren't tremendous, so I will describe app owns data.

您需要执行以下操作:

  • 注册一个应用程序 - 转到 dev.powerbi.com/apps 并注册一个本机应用程序.选择授予它的权限(如果您不确定,对于您的第一次测试,只需授予所有权限).复制 guid - 这是应用 ID,也就是客户端 ID.

  • Register an application - go to dev.powerbi.com/apps and register a native application. Select which permissions to grant it (if you aren't sure, for your first tests simply grant them all). Copy the guid - this is the app ID, a.k.a. client ID.

下一步是从您的应用程序进行身份验证并获取访问令牌.为此,请使用 Azure Active Directory 身份验证库 (ADAL) - 调用 AuthenticationContext 类的一些 acquireToken 方法.以下是适用于 Android 的官方示例.

Next step is to authenticate from your application and get an access token. Use Azure Active Directory Authentication Library (ADAL) for that - call some of the acquireToken methods of AuthenticationContext class. Here are the official examples for Android.

使用此访问令牌调用 Power BI REST API 并获取要嵌入的元素的 embedUrl,例如报告.

Use this access token to call the Power BI REST API and get the embedUrl of the element you want to embed, e.g. report.

使用 Power BI JavaScript 客户端 来实际嵌入这个元素.您需要初始化一个嵌入配置类并传递有关信息元素类型(报告、仪表板、磁贴)、在哪里找到它(embedUrl)、身份验证(访问令牌)、其他一些配置选项(显示或隐藏过滤器窗格、导航等)、要应用的过滤器等等.如果您将使用上面获取的访问令牌,请将 tokenType 设置为 AAD.此令牌具有许多特权,因此出于安全原因,您可能希望改用 Embed 令牌.在这种情况下,使用访问令牌再次调用 REST API(例如 报告 GenerateTokenInGroup).

Use Power BI JavaScript client to actually embed this element. You need to initialize one embed configuration class and pass information about element type (report, dashboard, tile), where to find it (embedUrl), authentication (access token), some other configuration options (show or hide filters pane, navigation, etc.), filters to be applied and so on. In case you will use the access token acquired above, set tokenType to be AAD. This token has many privileges, so for security reasons you may want to use Embed token instead. In this case use the access token to call the REST API again (e.g. Reports GenerateTokenInGroup).

调用 JavaScript 客户端的 powerbi.embed 方法传递嵌入式配置,以在您的应用中可视化此 Power BI 元素.

Call powerbi.embed method of the JavaScript client pass the embedded configuration to visualize this Power BI element in your app.

这篇关于2019年如何在Android原生应用中添加Power BI报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆