1. <legend id='aidXs'><style id='aidXs'><dir id='aidXs'><q id='aidXs'></q></dir></style></legend>

        <small id='aidXs'></small><noframes id='aidXs'>

      1. <tfoot id='aidXs'></tfoot>
          <bdo id='aidXs'></bdo><ul id='aidXs'></ul>
        <i id='aidXs'><tr id='aidXs'><dt id='aidXs'><q id='aidXs'><span id='aidXs'><b id='aidXs'><form id='aidXs'><ins id='aidXs'></ins><ul id='aidXs'></ul><sub id='aidXs'></sub></form><legend id='aidXs'></legend><bdo id='aidXs'><pre id='aidXs'><center id='aidXs'></center></pre></bdo></b><th id='aidXs'></th></span></q></dt></tr></i><div id='aidXs'><tfoot id='aidXs'></tfoot><dl id='aidXs'><fieldset id='aidXs'></fieldset></dl></div>

        如何解决有关导出的 Firebase 消息服务实现的 android lint 投诉?

        时间:2023-07-29
            <bdo id='4oC7i'></bdo><ul id='4oC7i'></ul>
            1. <small id='4oC7i'></small><noframes id='4oC7i'>

                  <tbody id='4oC7i'></tbody>
                <legend id='4oC7i'><style id='4oC7i'><dir id='4oC7i'><q id='4oC7i'></q></dir></style></legend>
                  <i id='4oC7i'><tr id='4oC7i'><dt id='4oC7i'><q id='4oC7i'><span id='4oC7i'><b id='4oC7i'><form id='4oC7i'><ins id='4oC7i'></ins><ul id='4oC7i'></ul><sub id='4oC7i'></sub></form><legend id='4oC7i'></legend><bdo id='4oC7i'><pre id='4oC7i'><center id='4oC7i'></center></pre></bdo></b><th id='4oC7i'></th></span></q></dt></tr></i><div id='4oC7i'><tfoot id='4oC7i'></tfoot><dl id='4oC7i'><fieldset id='4oC7i'></fieldset></dl></div>
                  <tfoot id='4oC7i'></tfoot>
                1. 本文介绍了如何解决有关导出的 Firebase 消息服务实现的 android lint 投诉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  按照 Google 开发人员关于在我的应用中实施 Firebase 的说明,我注意到 android lint 抱怨.

                  Following the Google developer instructions on implementing Firebase in my app, I notice that android lint complains.

                  我们的想法是我们必须实现两个继承自 Firebase 服务的服务:

                  The idea is that we have to implement two services which inherit from Firebase services:

                  public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { ... }
                  
                  public class MyFirebaseMessagingService extends FirebaseMessagingService { ... }
                  

                  然后在清单中注册这些服务.但是,它并不十分完美.特别是,这两个推荐的 AndroidManifest.xml 服务条目不包含任何特殊权限:

                  and then register those services in the manifest. But, it's not quite perfect. In particular, these two recommended AndroidManifest.xml service entries do not contain any special permissions:

                  <service android:name=".MyFirebaseMessagingService">
                      <intent-filter>
                          <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                      </intent-filter>
                  </service>
                  
                  <service android:name=".MyFirebaseInstanceIDService">
                      <intent-filter>
                          <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                      </intent-filter>
                  </service>
                  

                  所以 linter 说:

                  and so the linter says:

                  导出的服务(设置exported=true 或包含intent-filter 且未指定exported=false 的服务)应定义实体必须具有的权限才能启动服务或绑定到它.没有这个,任何应用程序都可以使用这个服务.

                  Exported services (services which either set exported=true or contain an intent-filter and do not specify exported=false) should define a permission that an entity must have in order to launch the service or bind to it. Without this, any application can use this service.

                  我是否应该将此属性添加到每个服务标签并完成它

                  Should I just add this attribute to each service tag and be done with it

                  tools:ignore="ExportedService"
                  

                  或者在这种情况下有更好的方法吗?我的意思是,像这样公开这些特定的 Firebase 派生服务是否安全?

                  or is there a better approach in this situation? I mean, is it safe to expose these particular Firebase derived services like this?

                  推荐答案

                  你问:...像这样公开这些特定的 Firebase 派生服务是否安全? 如果你相信这些评论在这些服务的清单文件中.

                  You ask: ...is it safe to expose these particular Firebase derived services like this? It is if you trust the comments in the manifest files for these services.

                  在 Android Studio 中,打开应用的 AndroidManifest.xml 文件.在窗口底部,选择 Merged Manifest 选项卡.滚动以找到 FirebaseMessagingService 的条目.双击包含服务名称的行.服务的清单文件应该会打开,您会看到:

                  In Android Studio, open your app's AndroidManifest.xml file. At the bottom of the window, select the tab for Merged Manifest. Scroll to find the entry for FirebaseMessagingService. Double-click on the line that contains the service name. The manifest file for the service should open and you will see this:

                  <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.firebase.messaging">
                      <uses-sdk android:minSdkVersion="14"/>
                  
                      <application>
                  
                          <!-- FirebaseMessagingService performs security checks at runtime,
                               no need for explicit permissions despite exported="true" -->
                          <service android:name="com.google.firebase.messaging.FirebaseMessagingService" android:exported="true">
                              <intent-filter android:priority="-500">
                                  <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                              </intent-filter>
                          </service>
                  
                      </application>
                  </manifest>
                  

                  注意注释:FirebaseMessagingService 在运行时执行安全检查,尽管exported="true"

                  您可以对 FirebaseInstanceIdService 执行相同操作并查看相同的注释.

                  You can do the same for FirebaseInstanceIdService and see the same comment.

                  如果您相信评论(我相信),您可以放心地忽略 lint 警告或禁用检查.

                  If you trust the comments (I do), you can safely ignore the lint warnings or disable the checks.

                  这篇关于如何解决有关导出的 Firebase 消息服务实现的 android lint 投诉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有 FCM 的 IOS 数据通知 下一篇:FCM - 在 onMessageReceived 中设置徽章

                  相关文章

                    1. <small id='w0vaI'></small><noframes id='w0vaI'>

                      <i id='w0vaI'><tr id='w0vaI'><dt id='w0vaI'><q id='w0vaI'><span id='w0vaI'><b id='w0vaI'><form id='w0vaI'><ins id='w0vaI'></ins><ul id='w0vaI'></ul><sub id='w0vaI'></sub></form><legend id='w0vaI'></legend><bdo id='w0vaI'><pre id='w0vaI'><center id='w0vaI'></center></pre></bdo></b><th id='w0vaI'></th></span></q></dt></tr></i><div id='w0vaI'><tfoot id='w0vaI'></tfoot><dl id='w0vaI'><fieldset id='w0vaI'></fieldset></dl></div>
                      <tfoot id='w0vaI'></tfoot>

                        <bdo id='w0vaI'></bdo><ul id='w0vaI'></ul>
                    2. <legend id='w0vaI'><style id='w0vaI'><dir id='w0vaI'><q id='w0vaI'></q></dir></style></legend>