Push notifications for Android

Someone use https://atmospherejs.com/activitree/push ?
I have problems with receiving messages on some android devices and the notification sound does not work, does anyone have experiences about it ?

Hi, I use it and also take care of it.
Are you using and sending a custom sound via the configuration? This package will not dictate whether the sound should play or not but rather if the sound is a custom or the default on device. You can check the official API here and see if you feel something is missing from the Meteor packages: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidconfig. It works ok for me even with a custom sound.

By “some Android devices” do you mean some brands or some random devices of eventually the same brand/model? Do you see those devices’ tokens in your DB? Do you see any errors in your Google API console? Perhaps if you activate debugging in the package, you could read sending errors on the server console.
I am not sure how I can help, your request for help is a little vague.

1 Like

Hi and thanks for the answer, who could give it to me better if not who made the plugin?! :slight_smile:
I think I followed all the official plugin directions here https://github.com/activitree/meteor-push
I have installed https://github.com/phonegap/phonegap-plugin-push 2.3.0.
I configured my application as in the example
My “push_methods.js” is identical and is in / lib
In server and client startups I put:

With active debugging I see in my console that everything is fine, the notification is sent and received by the Android device, you can hear the vibration but not the sound, I have done many tests but there is no way to make it sound.
the configuration files of github, the ones that I poked above, are fine, right ?
I would just like to get the default sound, I don’t have to customize it.
Can you give me some advice ?

excuse me @paulishca,
can you show me what value you set for “sound” key, in the various file ?
I have tray more and more, but don’t works in any way…

Hi @davideonmeteor I use the startup/server configuration as described in the repo/ example. I do use custom sounds. Those files in the example are exactly what I use in my projects. I suggest you check on the cordova-push-plugin side if there are people experiencing the same problem. You could also open a ticket for this matter and mention your exact versions not working and maybe somebody had the same experience. Initially you mentioned that some phones don’t get the messages or so. Is that still an issue for you? :

 sound: 'note',       // String (file has to exist in app/src/res/... or default on the mobile will be used). For Android no extension, for IOS add '.caf'

thanx @paulishca,
I have do it but no lucky…
I have also tried to set a console.log and error in “/lib/push_methods.js”, in:

run (notification) {
	// Add your Method Level security preference here.
	// if (!this.userId) {
	//    throw new Meteor.Error(404, 'No userId was set, userId was ' + userId)
	// }

throw new Meteor.Error(404, ‘error test’)

	// 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)

	// Doing some cleanup on useless keys of the notification object, if any.
	Object.keys(notification).map(key => (notification[key] === null || notification[key] === undefined) && delete notification[key]) 

The strange is that console.log is not display in my console, and no error… should appear, right ?!

If you can give me another indication:
For the sound, I extract myApp.apk, there isn’t a path like “app/src/res”, what is the right path where the audio file must be ? I use a audio file named ‘alya.ogg’.

I have done a little step forward…
I discovered that in notification option in the app, there is a PhoneGap PushPlugin and the audio was set to “audio supplied by the app”, if I change this setting and I choose a sound tone, the notification now will sound !
Now, I want to set a custom sound, because I don’t want users to have to set this manually.
In meteor you can set resource in mobile-config.js by "App.addResourceFile(‘sound1.mp3’, ‘res/raw/sound1.mp3’, ‘android’) but it doesn’t work.
adb logcat shows me this message “FileSource: Failed to open file ‘android.resource://app.myapp/raw/true’. (No such file or directory)”.
Isn’t it weird ? Why the path is “app.myapp/raw/true”, I was expecting “app.myapp/raw/sound1.mp3”.
How did you set “App.addResourceFile(‘sound1.mp3’, ‘res/raw/sound1.mp3’, ‘android’)” exactly ? (obviously using “note” instead of “sound1”).

Maybe is this issue ?

I think I understand the problem, it is a bug of the Cordova component https://github.com/phonegap/phonegap-plugin-push which misprints the path of the sound file (that’s why in the logcat appears "FileSource: Failed to open file ‘android.resource: //app.myapp/raw/true’. (No such file or directory) ".
I then simply removed the “sound” key in “https://github.com/activitree/meteor-push/blob/master/example/app/startup/client/index.js” and now the notification plays the default sound , if you want to customize the sound you have to do it from the settings of the Cordova plugin in the device itself.
Another consideration is that this behavior I have on Android 9, on Android 7 instead it works well and on Android 8 I was unable to try it.
@paulishca, I don’t know why it worked the same for you, maybe your app is only used on Android 7, or you have an old version of the Cordova plugin.

Sorry @paulishca , can you give me a feedback about it ?
It would be very important for me to understand this…
Thank you.

Hi @davideonmeteor I am not an expert in Android. This package leverages on existing Cordova plugins which are not in my control. Simply put, any Cordova plugin has hooks in both directions. In my case Meteor <–>Cordova Plugin <–>Android. I only control Meteor + the hooks into the Cordova plugin. The plugin itself and what is left of the entire ‘ecosystem’ are not in the scope of this package. However, if you find a feature in Firebase Admin (FMC) or Cordova plugin that is not implemented, you can open a PR in the package itself and have it implemented or open a ticket and wait for somebody to do it.
I hope this helps.

1 Like

thank you so much for your answer it’s really help full i am also facing same issue but now my issue resolved thank for helping

1 Like

@davideonmeteor this you get your Push working?

yes, with Push notifications for Android

Hi, for general info: With the same push plugin, I also had to change the sound: setting in the client-init from true to default to get the default sound to play.

are you sure ?
In my project I had disable this parameter due to No default notification sound from default PushPluginChannel in Android 8+ · Issue #2584 · phonegap/phonegap-plugin-push · GitHub , is a open bug.

Hi, yes.

We’re using phonegap-plugin-push@2.3.0 and it seems to be working.

I also send this with the payload:

sound: isSilentPush ? '' : 'default',

And I get the sound now.

I’ve explained here on last Friday how I send push notifications in my apps

Building Native Apps in Hours with Meteor | Dourados, Brazil Meetup (English)

1 Like

yes, but in your presentation you using onesignal for push notifications service, not firebase, so activitree-push plugin doesnt works.
@filipenevola do you think is a good choice not using Firebase service (Google services) ? What about using resource for a new service, for battery, network…

Hi, why activitree-push doesn’t work? Could you submit a fix for what you found not working, please.

I mean with onesignal.com don’t works, with firebase (Google service) ther is’nt problem, works good.
Or I’m wrong ? @paulishca activitree-push can use with onesignal.com ?