Hi, activitree:push no longer depends on RAIX packages and I would need your help to test the new version in an active Cordova project before I push to Atmosphere. Web Push is ok, I could test it myself in production.
Please, up on your availability run this exercise and let me know if all looks good or as good as before: https://github.com/activitree/meteor-push/issues/28#issuecomment-688829808
Also, in your project you can do an extra route and add this button and method for your test. In your _push_tokens collection in Mongo you should see tokens of all IOS, Androi and Web. You can also click the button multiple times or generate multiple calls to the method on a single click (e.g 100)so you can observe the batch sending and the server load (should be pretty much 0 visible impact on CPU or RAM).
const sendNotificationTest = () => {
console.log('send')
Meteor.call('userPushNotification', {
userId: '....', // a test user's id.
title: 'A Test Notification ',
body: 'Getting this message.',
badge: 1
}, err => {
if (err) {
console.log(err)
}
})
}
<button className='btn btn-primary' type='button' onClick={sendNotificationTest}>Test</button>
// The Meteor Method (sits in a common folder):
export const userPushNotification = new ValidatedMethod({
name: 'userPushNotification',
validate: new SimpleSchema({
title: String,
body: String,
badge: Number,
userId: String,
topic: { type: String, optional: true },
sound: { type: String, optional: true },
icon: { type: String, optional: true },
color: { type: String, optional: true },
vibrate: { type: Boolean, optional: true },
contentAvailable: { type: Boolean, optional: true },
launchImage: { type: String, optional: true },
category: { type: String, optional: true },
threadId: { type: String, optional: true },
delayUntil: { type: Date, optional: true },
token: { type: String, optional: true },
tokens: { type: Array, optional: true },
'tokens.$': { type: String, optional: true },
from: { type: String, optional: true },
data: { type: Object, blackbox: true, optional: true },
action: { type: String, optional: true }
}).validator(),
run ({
title,
body,
badge,
userId,
topic,
sound,
icon,
color,
vibrate,
contentAvailable,
launchImage,
category,
threadId,
delayUntil,
token,
tokens,
from,
data,
action
}) {
if (userId === '' || userId === undefined || userId === 'undefined') {
throw new Meteor.Error(404, 'No userId was set, userId was ' + userId)
}
// topic in IOS and Android have different behaviors. In IOS it must be set as the app id,
// in Android a notification can be sent to a topic (to its subscribers)
if (this.userId) {
const notification = {
title,
body,
badge,
userId,
notId: Math.round(Date.now() / 1000)
}
if (topic) { notification.topic = topic }
if (icon) { notification.icon = icon }
if (color) { notification.color = color }
if (sound) { notification.sound = sound }
if (contentAvailable) { notification.contentAvailable = contentAvailable }
if (launchImage) { notification.launchImage = launchImage }
if (category) { notification.category = category }
if (threadId) { notification.threadId = threadId }
if (delayUntil) { notification.delayUntil = delayUntil }
if (token) { notification.token = token }
if (tokens) { notification.tokens = tokens }
if (from) { notification.from = from }
if (vibrate) { notification.vibrate = vibrate }
if (data) { notification.data = data }
if (action) { notification.action = action }
this.unblock()
Push.send(notification)
}
}
})