我们使用GCM (Google Cloud Messaging) 来进行推送通知。当我们使用play-services:8.3.0时,一切正常。我们使用自己的接收器来处理推送通知。但是在升级到com.google.android.gms:play-services:8.4.0
后,推送通知不再通过myGcmListenerService到达,而是直接显示在通知栏中。同时,日志中会出现以下错误:GcmAnalytics: Error while parsing timestamp in GCM event.
在8.3.0中,我们接收到的推送如下所示:
Bundle[{gcm.notification.e=1, google.c.a.ts=234343426, gcm.notification.badge=1, gcm.notification.sound=default, gcm.notification.sound2=default, gcm.notification.body=John M @ Cords, Wires And Cable Ftu, gcm.notification.data={"name":"new_chat_message","message_id":490666,"channel_id":5366}, google.c.a.e=1, collapse_key=com.domain.app.debug}]
在8.4.0中,推送通知的格式如下:
Bundle[{notification=Bundle[{sound2=default, e=1, body=John M @ Cords, Wires And Cable Rrr, data={"name":"new_chat_message","message_id":490641,"channel_id":5366}, badge=1, sound=default}], collapse_key=com.domain.app.debug}]
通知 - GCM会代表客户端应用程序自动向最终用户设备显示消息。
和数据 - 客户端应用程序负责处理数据消息。
问题在于,除了Android之外,我们还需要支持IOS客户端,因此我们需要将通知用于IOS(以处理系统推送),并将数据用于Android(以处理我们自己的推送)。 - Rafael