Closed droidxnd closed 8 years ago
Hi @droidxnd,
I'm going to ask the obvious -- are you sure you subscribed your test device to/topics/MyAppName
?
This is done via the Android client-side code.
GcmPubSub pubSub = GcmPubSub.getInstance(this);
pubSub.subscribe(token, "/topics/" + topic, null);
Hello @eladnava!!
I already added this code to my App before :
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/MyAppName" + topic, null);
}
}
and added this code to check the type of message (Topic or Token)
if (from.startsWith("/topics/MyAppName")) {
Log.d(TAG, "This message is sent from Topic");
// message received from some topic.
} else {
Log.d(TAG, "This is normal GCM Message");
// normal downstream message.
}
@droidxnd According to the code you posted, your app subscribes via:
pubSub.subscribe(token, "/topics/MyAppName" + topic, null)
Which is not the same as:
pubSub.subscribe(token, "/topics/MyAppName", null)
.
Could it be a mistake?
@eladnava Oh my, I'm embarrassed about I missed that. Thanks, sir!
Good thing that you asked the question, though, @droidxnd --- and this is indeed the right place for this kind of question :smile:
Please keep us posted if anything else seems to act up. Good luck with your project!
I wonder if there's any mail address or anything on your profile to ask the questions, but I couldn't find them. Sorry about asking questions at here.
I had following codes and tried send the push to topic and prompt gave me a message_id, but push is not received on Android App. Is it problem of my android client?
var gcm = require('node-gcm');
var message = new gcm.Message();
message.addData('title', 'This is a Title!'); message.addData('message', 'This is a Description!');
var sender = new gcm.Sender('AIzaS....');
sender.sendNoRetry(message, { topic: '/topics/MyAppName }, function (err, response) { if(err) console.error(err); else console.log(response); });