fcm ionic custom sound - ionic-framework

I am using ionic with the ionic native plugin FCM. I have everything working, except I am unable to get my device to play a custom sound. Is this supposed to be the sound that plays when app is not in foreground (because no sound should play in foreground)? I have followed the instructions and placed "sound":alarm1" in both the notification, and/or data payload, and removed the notification payload all together. alarm1.mp3 is in the res/raw directory as well. I have used "sound":"alarm1" and "sound":"alarm1.mp3" in all of the cases also. What am I missing? I need to get the device to play 1 of 3 sounds on receipt of FCM.
I continue to get the default device notification sound is all cases.

Related

Incoming call notification

We are developing an app with angular/ionic in which we use capacitor jitsi plugin for video calls. What we are now trying to do is to receive notifications (via firebase) like in whatsapp with the incoming call screen and two buttons to accept and decline. Any idea on how to do that?
Thanks
If you got the choice to change the notification service, instead or directly using firebase, you could use Onesignal which extends firebase and they already have a service named VOIP notifications which should kinda do your needs and here is the link:
https://documentation.onesignal.com/docs/voip-notifications
In case your are restricted with firebase or need to know how this could be done, bellow will be the way to achieve it..
As for android:
First as logic part, you need to add some code in the native layer since hybrid apps usually can't interact from JavaScript side to native side in case app was not launched, so in order to wake the application on a specific event like notification received or any other actions that phone system can hold..
Second, as technical part, you need to add broadcast receivers and the receivers role stand to interact as native code with system. example in the link below:
https://www.digitalocean.com/community/tutorials/android-broadcastreceiver-example-tutorial
also another video about foreground and background broadcast receiver service in the link below:
https://www.youtube.com/watch?v=rlzfcqDlovg
video code output in git:
https://github.com/borntocoderepos/callrecorder
in the Youtube video example, the user is launching a toast message on phone call if app was opened or closed (background or foreground) so you can launch your app with intent with passing data and capture the data on app start as Deep Links as capacitor (https://capacitorjs.com/docs/guides/deep-links) or Cordova (https://ionicframework.com/docs/native/deeplinks)..
And instead of listening to network or phone calls, you can listen to Notifications and for sure you need to do searches about your topic and or the notification service that you'll choose.
Now for the video and the tutorial not sure of the quality of code so make sure to do more researches about the way its done from different places (could be outdated code or bad code quality or even not complete service and will discuss about this point below).
In android there is policy about using background and foreground services so once you start a service you need to end it after your done so make sure after you receive the notification and launch your app to stop the listening since it would cost power usage and perhaps could be stopped by Playstore as harmful app.
Now considering IOS it should be the same concept so make searches about this topic, but for IOS, the listeners policy as I remember , the receivers should not be waked up for more than 15 mins, so also keep this in mind and make sure you stop the receivers directly after launching your Hybrid app.
Broadcast equivalent receiver for IOS:
http://www.andrewcbancroft.com/2014/10/08/fundamentals-of-nsnotificationcenter-in-swift/

Google chat sound notifications are incorrect

Despite changing the notification sound in the sound menu, Google chat app continues to use the hangouts sound. How do I change this? (I have uninstalled the app and re-installed several times)

Reading accelerometer data while the app is running in background

I want to build an Ionic app that can still use accelerometer data while the app is minimized (runs in the background).
I have tried using:
The Ionic Device Motion Plugin
https://ionicframework.com/docs/native/device-motion
The Device Motion Web API that is supported by browsers https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent
The Generic Sensor API that is documented to be supported by Chrome browser https://developers.google.com/web/updates/2017/09/sensors-for-the-web
The first two work in the foreground but won't work while the app is in the background (the accelerometer readings are paused and are resumed while on the foreground again). The Generic Sensor API won't work at all, even if I use this polyfill: https://github.com/kenchris/sensor-polyfills
I have also tried the Ionic Background Mode plugin, however, the accelerometer reading are still being paused in background.
https://ionicframework.com/docs/native/background-mode
How can an Ionic app use the accelerometer while in background? Any plugin that I am not aware of its existence (e.g., the Ionic Background Geolocation lets the app receive locations while in background)? Any other way?

No delegates were triggered if app is in backgroundmode

I am at the beginning with RestKit-development. I develop an app that
get data from a Server and map these in objects. With a trick of
silence music, is it possible to send request to the backend, if the
app is in background mode . If I
leave the app the request will send, but the delegate of "finish with
objectmapping" will not throw, but if I start (activate the app) the
app, the delegates
will fire. Is there are a way, to map the json if the app is in
background mode?
I've provided an answer to your other post which I think will help you here. See link:
Your other post
Yes, if you configure your application to have a background mode that plays music and play audio while you want your application to continue to run. You can use a silent audio file if you don't actually want to play music so long as you don't want to distribute it through the App Store, but Apple will not approve it for the App Store unless there is actual music as an actual feature in your application.

Do iphone push notifications send the actual sound data to play, just a filename, or is it handled by the app?

And, does it cache it locally?
I ask because I am wondering if it's possible to change the sound of a push notification via SSH, replacing an app sound.
My question is specifically about how the API for push notifications works. Does it send a .caf (aiff) binary file for the phone to play each time?
There is no file being sent. You can add a sound name for a file that's stored in your app which you want to be played when the notification arrives. See the Apple Push Notification Service Programming Guide for further assistance.