在Firebase中以编程方式实现Android通知
在没有后端的android中发送通知,我们必须在android studio中编写以下代码行:在Firebase中以编程方式实现Android通知,android,firebase,firebase-notifications,Android,Firebase,Firebase Notifications,在没有后端的android中发送通知,我们必须在android studio中编写以下代码行: NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Intent intentViewPost = new Intent(PostsActivity.this,BlogPostsView.class); PendingIntent pendingIntent = Pen
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent intentViewPost = new Intent(PostsActivity.this,BlogPostsView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(PostsActivity.this,(int) System.currentTimeMillis(), intentViewPost,0);
Notification notification = new Notification.Builder(getBaseContext())
.setSmallIcon(R.mipmap.ic_app_logo)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(postTitle)
.setContentIntent(pendingIntent)
.build();
manager.notify(111,notification);
如果不使用控制台,如何在Firebase中执行相同的操作。向特定设备发送消息 要向特定设备发送消息,请将设置为特定应用程序实例的注册令牌
curl -H "Content-type: application/json" -H "Authorization:key=<Your Api key>" -X POST -d '{ "data": { "score": "5x1","time": "15:10"},"to" : "<registration token>"}' https://fcm.googleapis.com/fcm/send
curl-H”内容类型:application/json“-H”授权:key=“-X POST-d'{“data”:{“score”:“5x1”,“time”:“15:10”},to”:“}”https://fcm.googleapis.com/fcm/send
向主题发送消息
这里的主题是:/topics/foo-bar
curl -H "Content-type: application/json" -H "Authorization:key=<Your Api key>" -X POST -d '{ "to": "/topics/foo-bar","data": { "message": "This is a Firebase Cloud Messaging Topic Message!"}}' https://fcm.googleapis.com/fcm/send
curl-H“Content-type:application/json“-H”Authorization:key=“-X POST-d'{“to”:“/topics/foo bar”,“data”:{“message”:“这是Firebase云消息主题消息!”}”https://fcm.googleapis.com/fcm/send
向设备组发送消息
向设备组发送消息与向单个设备发送消息非常相似。将to参数设置为设备组的唯一通知密钥
curl -H "Content-type: application/json" -H "Authorization:key=<Your Api key>" -X POST -d '{"to": "<aUniqueKey>","data": {"hello": "This is a Firebase Cloud Messaging Device Group Message!"}}' https://fcm.googleapis.com/fcm/send
curl-H”内容类型:application/json“-H”授权:key=“-X POST-d'{“to”:
这并不能回答我的问题