Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: registration_ids must be a string or an array of 1 element #5

Open
barryloh opened this issue Dec 28, 2013 · 4 comments
Open

Comments

@barryloh
Copy link

Hello there,

I've tried declaring

var registration_ids = ['regid1', 'regid2'];

and

var registration_ids = 'regid1';

But it doesnt seem to work. I keep coming back to that error

@ghost
Copy link

ghost commented Dec 28, 2013

Hi,

Can you give your code that create this issue ?

Thanks.

@barryloh
Copy link
Author

var gcm = require('node-gcm-service');

var message = new gcm.Message();
message.setDataWithObject({
key1: 'GCM Push Message'
});
message.setDryRun(false);
message.setDelayWhileIdle(false);

var sender = new gcm.Sender();
sender.setAPIKey('apikey');

var registration_ids = ['regid1', 'regid2'];

sender.sendMessage(message.toString(), registration_ids, false, function(err, data) {
if (!err) {
console.log('Message sent successfully');
console.log('Result: ' + err);
}
else {
console.log('MESSAGE NOT SENT. ERRRORRR *******************');
console.log('Error: ' + err);
}
});

@ghost
Copy link

ghost commented Dec 30, 2013

Hi,

I found the bug and correct it (2c125c1). I just publish a newer version of module v0.2.8.

Close this issue when all is good for you.

@silentjohnny
Copy link

This doesn't fix the problem. Now an array <= 1000 elements will generate up 1000 requests that all fail because of the registration_ids being a string now.

I guess it should be like this:

if (registration_ids.length <= 1000)
    return callback([registration_ids]);

@silentjohnny
Copy link

Or maybe better:

if (registration_ids.length <= 1000)
array.push(registration_ids);

@flocsy
Copy link

flocsy commented Jul 25, 2014

Unfortunatelly this is still not fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants