简体   繁体   English

将通知推送到Android应用(GCM)

[英]Push Notifications To Android App (GCM)

Looking to integrate push notifications for the first time to an Android app. 希望将推送通知首次集成到Android应用中。

I have done this for an iOS app using APNS, generally speaking I just want the notification to alert the user, I don't want to handle it within the app. 我已经针对使用APNS的iOS应用完成了此操作,通常来说,我只希望通知能够提醒用户,而不希望在应用中处理通知。

With iOS I can do this via broadcasting to APNS and the app isn't concerned with the notifications. 使用iOS,我可以通过广播到APNS来做到这一点,而该应用程序与通知无关。 Whereas from my reading on Android the app needs to register and listen for these updates within the app. 从我在Android上的阅读来看,该应用程序需要在应用程序中注册并收听这些更新。

Is this correct? 这个对吗?

From my reading on Android the app needs to register and listen for these updates within the app. 根据我在Android上的阅读内容,该应用程序需要注册并在应用程序中收听这些更新。

Is this correct? 这个对吗?

Depends on your use case. 取决于您的用例。 If you want to have control over to which specific device(s) the push is sent, then yes, you must obtain the registration id in the app and store it on a server. 如果要控制将推送发送到哪个特定设备,则可以,必须在应用程序中获取注册ID并将其存储在服务器上。 This id is used by google to find the device to which the push has to be sent. 谷歌使用该ID查找必须将推送发送到的设备。 You can then construct a message to push and use the registration ids to tell google where to push the message to. 然后,您可以构造一条要推送的消息,并使用注册ID来告诉Google将消息推送到何处。

However, with Firebase Console (Google Cloud Messaging is Firebase Cloud Messaging nowadays (same product, different name)) it is also possible to send push notifications to a certain target group you can specify. 但是,使用Firebase控制台(如今,Google Cloud Messaging是Firebase Cloud Messaging(产品相同,名称不同)),也可以将推送通知发送到您可以指定的特定目标组。 For example, you can use the Firebase Console send a push notification to all users that have made in app purchases in your app. 例如,您可以使用Firebase控制台向所有在您的应用中购买应用的用户发送推送通知。 The Firebase Console is a web interface where you manage your Firebase app/users/functionality etc. Firebase控制台是一个Web界面,您可以在其中管理Firebase应用程序/用户/功能等。

Note that sending push notifications directly from the Firebase Console comes with certain restrictions/limits regarding message customization that sending it yourself would not have. 请注意,直接从Firebase控制台发送推送通知具有一些与消息自定义有关的限制/限制,而您自己发送消息不会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM