This is an example of how raix:push
works at a minimal level.
Depending on the platforms you want to work with you will need some credentials or certificates.
Add a config.push.json
file in your project and configure credentials / keys / certificates:
{
"apn": {
"passphrase": "xxxxxxxxx",
"key": "apnProdKey.pem",
"cert": "apnProdCert.pem"
},
"gcm": {
"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"projectNumber": xxxxxxxxxxxx
},
"production": true
}
You can send push notifications to all users from client and server - Use browser console or Meteor shell:
Push.send({
from: 'Test',
title: 'Hello',
text: 'World',
badge: 12,
query: {}
});
If you remove the insecure
package from Meteor you have to explicitly allow users to send push notifications from client-side.
common.js
Push.allow({
send: function(userId, notification) {
// Allow all users to send to everybody - For test only!
return true;
}
});
Try adding the Meteor accounts-password
package and let users login. Try sending a push notification to a user:
Push.send({
from: 'Test',
title: 'Hello',
text: 'World',
badge: 12,
// sound: fileInPublicFolder
query: {
userId: 'xxxxxxxxxxxx'
}
});
Help me fix bugs - you can enable debugging by setting Push.debug = true;
- This will log details about whats going on in the system.
Kind regards
Morten (aka RaiX)