简体   繁体   English

Android通知-多个用户的推送通知

[英]Android notifications - push notifications for multiple users

I am writing an app in which you can create and invite multiple users to an event. 我正在编写一个应用程序,您可以在其中创建并邀请多个用户参加活动。 I would like to have the app send notifications to users when they are invited to an event. 我想让应用程序在受邀参加活动时向用户发送通知。 I am calling the following in my button onClick method to send notifications when an event is created. 我在按钮onClick方法中调用以下命令,以在创建事件时发送通知。

private void addNotification() {
    NotificationManager notif=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notify=new Notification.Builder
            (getApplicationContext()).setContentTitle("Hello").setContentText("This is a notification").
            setContentTitle("notif").setSmallIcon(R.mipmap.ic_launcher).build();

    notify.flags |= Notification.FLAG_AUTO_CANCEL;
    notif.notify(0, notify);
}

This works, however this only sends the push notification to me when the event is created. 这有效,但是仅在创建事件时才向我发送推送通知。 I'm not sure how to have it send to the multiple people invited to the event. 我不确定如何将其发送给受邀参加活动的多个人。 I have a list of the user emails I want to notify. 我有要通知的用户电子邮件列表。 How can i change this code to send a notification to multiple users? 如何更改此代码以向多个用户发送通知?

for this you can use google cloud messaging. 为此,您可以使用Google云消息传递。 It will help you to broadcast the notification to multiple users 它将帮助您将通知广播给多个用户

https://developers.google.com/cloud-messaging/android/client https://developers.google.com/cloud-messaging/android/client

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

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