多个Receiver用于跨应用程序的FCM中的相同操作

时间:2014-02-25 07:24:05

标签: android push-notification google-cloud-messaging

当我们在Android中实施GCM(Google云消息传递)时,我们必须在每个应用程序中提供接收器。根据我的知识,如果你有多个应用程序有自己的接收器映射为共同的行动"com.google.android.c2dm.intent.RECEIVE"。每个应用程序内的接收器应该调用但不是,我想知道android如何识别哪个应用程序的接收器应该调用?

 <receiver
        android:name=".GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="com.google.android.gcm.demo.app" />
        </intent-filter>
    </receiver>

1 个答案:

答案 0 :(得分:1)

在GCM广播接收器的intent过滤器的category中指定包名称时,将com.google.android.c2dm.intent.RECEIVE操作的范围缩小到应该传递GCM消息的特定应用程序的范围到。