parse-community / parse-server-push-adapter

A push notification adapter for Parse Server
https://parseplatform.org
MIT License
88 stars 100 forks source link

pushing to thousands of installations #9

Closed fasa23 closed 8 years ago

fasa23 commented 8 years ago

Im currently sending push notifications to my app from my parse-server on DigitalOcean.

I have almost 20K installations and when I send a push to all of them, it takes almost 20 min to be received on the iphone. In my case this is awfull because I notify soccer matches and users want to know as soon as their team scores a goal. Ive seen on the parse-server documentation that push notifications "Does not support super high throughput since it does not employ a job queue system" and im assuming the server is sending push notifications one by one and thats why my console logs every second:

"Notification transmitted to:" + device.token. But it takes to much time to receive the notification on the iPhone, I think my token is one of the last on that loop.

I would like to know if i can modify any file to avoid the loop and send the push notification faster, Ive found a file under parse-server/node_modules/apn/examples/sending-to-multiple-devices.js where I found this function

// If you plan on sending identical paylods to many devices you can do something like this.
function pushNotificationToMany() {
    console.log("Sending the same notification each of the devices with one call to pushNotification.");
    var note = new apn.notification();
    note.setAlertText("Hello, from node-apn!");
    note.badge = 1;

    service.pushNotification(note, tokens);
}

So. Is there a way i can call to this function from cloud code? because when I use Parse.Push.send() from cloud code I assume my server is using this other function (service.on) inside sending-to-multiple-devices.js and thats why i get that log on my console each second

service.on("transmitted", function(notification, device) {
    console.log("Notification transmitted to:" + device.token.toString("hex"));
});

Im currently using no adapters to push my notifications, Ive seen OneSignal is a great option but the problem is that users who dont update the app will still be hitting parse installations records (so their subscriptions to soccer teams might be modified and I wouldnt be capable of noticing it) I would be really happy if theres an alternative in wich I dont have to implement any Push Adapter

Sorry for my english

flovilmart commented 8 years ago

I'd gladly accept a PR for using the token list, that should not be that difficult to implement.

fasa23 commented 8 years ago

Please could you implement it? And also please give an example on how to use that token list directly from cloud code. I'm pushing to users who are subscribed to a Channel using parse.query to get the users installations who have to receive the goal-scored notification.

flovilmart commented 8 years ago

Please test from #10

If you wanna use if from cloud code, I can't really help, I'm not a hotline for special implementation needs.