为什么我应该在我的 android 应用程序中为 GCM 定义权限标签?

Why should I define permission tag in my android app for GCM?

我正在阅读 GCM 文档,一件事让我问了这个问题:为什么我需要在我的清单中定义权限标签而不是使用我定义的权限?

代码如下:

<permission android:name="<your-package-name>.permission.C2D_MESSAGE" android:protectionLevel="signature" />

<uses-permission android:name="<your-package-name>.permission.C2D_MESSAGE" />

这个权限是不是应该定义在service app里面,我加了uses-permission

如果需要使用 permission 标签,signature 级别在这里做什么?

我正在定义一个权限,除我之外不允许任何人使用它!

GCM

需要包级权限才能识别特定的应用程序来传递消息。

来自docs

Your + ".permission.C2D_MESSAGE" permission to prevent other Android applications from registering and receiving the Android application's messages. The permission name must exactly match this pattern—otherwise the Android application will not receive the messages

对于 例如 考虑这些权限就像 phone 数字和 android 是建筑物。建立呼叫时建筑物中可能有太多人 link 但每个接收器都有自己唯一的 phone 号码,在此基础上,呼叫连接到该特定接收器。

签名级别:这是为了确认应用程序是由您在您的系统上签名的,该系统具有与您在 [=11= 上使用的相同 SHA-1 密钥] 安慰。如果满足此条件,将立即授予 C2D 权限。