Reputation: 37
I am able to sent a custom notification to my own device using Advanced REST Client using this code:
https://fcm.googleapis.com/fcm/send
content-type application/json
Authorization KEY=XXXXXXXXXX
{
"data": {
"title": "Update",
"content": "Test"
},
"to": "cju4nq0nQ9C8YAkVZZ_lh7:APA91bG........
}
I have no idea how to send this to all users. I read something about using topics, but don't know how to apply that here.
Can you point me in a direction or have a solution for this problem?
Upvotes: 0
Views: 337
Reputation: 37
What I did was assign all users to the same topic using this:
FirebaseMessaging.getInstance().subscribeToTopic("leden")
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String msg = getString(R.string.msg_subscribed);
if (!task.isSuccessful()) {
msg = getString(R.string.msg_subscribe_failed);
}
Log.d(TAG, msg);
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
}
});
Then in the Advanced REST Client (Google Chrome Extention):
{
"data": {
"title": "Update",
"content": "Test"
},
"to": "/topics/leden"
}
Upvotes: 1