Here is a nice documentation on how to implement Google Cloud Messaging (GCM) in Chrome. But I do not found any reference here or anywhere how to subscribe to a topic using javascript (for Chrome).
Here I have found a reference how to do the task for Android: https://developers.google.com/cloud-messaging/topic-messaging#subscribe-to-a-topic
Java code(Android) for subscribe to a topic in GCM:
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null);
}
}
WHAT I AM NOT LOOKING FOR
I am NOT looking ways for Chrome app/Extension.
WHAT DO I WANT
I want to send push notification to all my users. So far I know this can be achievable in two ways:
- Push message to a topic
- Or I have to: "You need to send the list of reg id of devices and also this list should not exceed 1000 this is a limitation of GCM if you want to send message to more than 1000 devices then you need to break the list in chunks of 1000."
I want to avoid point number 2.
MY QUESTION
So, My question is is there any way to subscribe to a topic for GCM using Javascript for Chrome browser (for web pages)? If there, then how to do that?