从应用服务器接收 GCM 推送通知消息的步骤
Steps to receive GCM push notification message from app server
我们正在 IOS 和 Android 中开发应用程序。 GCM 推送通知已为 IOS 启用,现在工作正常。两个平台的包名称将相同。
ios 开发人员给了我 SERVER API KEY 和 SENDER ID 来为 android 设置 gcm。在查找步骤时,我遇到了 https://developers.google.com/cloud-messaging/android/client。
我一直告诉自己需要完成内容中列出的步骤才能为 android 设置 GCM(如果我错了请纠正我)。
- 获取配置文件并将其添加到Android项目
- 设置Google播放服务(我在我的项目依赖中添加了gcm)
- 向清单文件添加条目
- 检查 google 播放服务 APK
- 获取注册令牌。
"An Android application needs to register with GCM connection servers before it can receive messages"
"The client app should store a boolean value indicating whether the registration token has been sent to the server." - 我的后端团队告诉我,我不需要向他们发送任何我需要的东西,只需在应用程序中配置 gcm,应用程序就会从后端接收消息。
所以,我的问题是我是否需要 RegistrationIntentService 和 MyInstanceIDListenerService。另外,我是否必须在清单中定义我的 InstanceIDListenerService?
我们的后端使用设备 ID 向设备发送推送通知,因此他们不需要在我们发送设备 ID 时向他们发送注册令牌。所以在这种情况下,我应该使用 RegistrationIntentService 和 InstanceIDListenerService 向 GCM 注册我的应用程序吗?如果是这样,应用程序是否应该保留注册令牌。需要注册吗?
GCM 支持三种类型的下游(服务器到客户端)消息传递:发送到特定设备(也称为 "simple" 或 "targeted")、发送到主题或发送到设备组。你的问题是,"our backend uses device id to send push notifications to devices"。目前尚不清楚 "device ID" 是什么以及您打算使用哪种类型的消息传递。您的后端团队告诉您 "don't need to send them anything"。如果那是真的,我不知道他们从哪里得到 "device ID".
GCM 提供的三种消息传递类型中的每一种都需要客户端设备向 GCM 注册并获取注册令牌。要向特定设备发送消息,注册令牌实际上是 "device ID"。所以是的,您需要实现类似于 documentation.
中描述的 RegistrationIntentService
和 InstanceIDListenerService
的东西
文档中关于需要将注册令牌发送到应用服务器的描述具有误导性。这仅是有针对性的消息传递所必需的。 documentation for receiving topic messages 状态:"Note that, for topic messaging it's not required to send the registration token to your app server; however, if you do send it, your server can verify the validity of the token and get more information about the app that created it."
我们正在 IOS 和 Android 中开发应用程序。 GCM 推送通知已为 IOS 启用,现在工作正常。两个平台的包名称将相同。
ios 开发人员给了我 SERVER API KEY 和 SENDER ID 来为 android 设置 gcm。在查找步骤时,我遇到了 https://developers.google.com/cloud-messaging/android/client。
我一直告诉自己需要完成内容中列出的步骤才能为 android 设置 GCM(如果我错了请纠正我)。
- 获取配置文件并将其添加到Android项目
- 设置Google播放服务(我在我的项目依赖中添加了gcm)
- 向清单文件添加条目
- 检查 google 播放服务 APK
- 获取注册令牌。
"An Android application needs to register with GCM connection servers before it can receive messages"
"The client app should store a boolean value indicating whether the registration token has been sent to the server." - 我的后端团队告诉我,我不需要向他们发送任何我需要的东西,只需在应用程序中配置 gcm,应用程序就会从后端接收消息。
所以,我的问题是我是否需要 RegistrationIntentService 和 MyInstanceIDListenerService。另外,我是否必须在清单中定义我的 InstanceIDListenerService?
我们的后端使用设备 ID 向设备发送推送通知,因此他们不需要在我们发送设备 ID 时向他们发送注册令牌。所以在这种情况下,我应该使用 RegistrationIntentService 和 InstanceIDListenerService 向 GCM 注册我的应用程序吗?如果是这样,应用程序是否应该保留注册令牌。需要注册吗?
GCM 支持三种类型的下游(服务器到客户端)消息传递:发送到特定设备(也称为 "simple" 或 "targeted")、发送到主题或发送到设备组。你的问题是,"our backend uses device id to send push notifications to devices"。目前尚不清楚 "device ID" 是什么以及您打算使用哪种类型的消息传递。您的后端团队告诉您 "don't need to send them anything"。如果那是真的,我不知道他们从哪里得到 "device ID".
GCM 提供的三种消息传递类型中的每一种都需要客户端设备向 GCM 注册并获取注册令牌。要向特定设备发送消息,注册令牌实际上是 "device ID"。所以是的,您需要实现类似于 documentation.
中描述的RegistrationIntentService
和 InstanceIDListenerService
的东西
文档中关于需要将注册令牌发送到应用服务器的描述具有误导性。这仅是有针对性的消息传递所必需的。 documentation for receiving topic messages 状态:"Note that, for topic messaging it's not required to send the registration token to your app server; however, if you do send it, your server can verify the validity of the token and get more information about the app that created it."