how can i play a sound when device receive an C2DM message - android

i have read for hours about how to start play a sound the way i want
but i cannot find an answer.
Here goes,
When device receive a C2DM push im displaying a Notification.
User can click the Notficationand my activity start.
Everything works grate.
Now I would like to create a phone-call-type of ring-sound
so it sounds like there's an incoming Voice call.
User pick up phone and notice my Notification presses it
and the sound stop playing.
Or even better, the C2DM message trigger my activity to start
with a phone-call-type of ring-sound.
When user touch the phone the sound stop playing
any help in any direction would be grate

Set the sound data member of your Notification to a Uri pointing to the ringtone you want to have played when the Notification is displayed. Ideally, you let the user pick their own ringtone (e.g., via a RingtonePreference) rather than forcing a certain ringtone on them.
Or even better, the C2DM message trigger my activity to start with a phone-call-type of ring-sound.
Popping up an activity like this, when the user might be in the middle of something else, is infrequently a good idea.

Related

Can I make an iOS/Android app "ring", to force the user to respond to a push notification?

I have a food ordering app and I need to inform the restaurants of a new order. I have a Capacitor app which often runs in the background of tablets/phones of the restaurant. As a result, they sometimes miss an order.
In order to solve this, it would be great if I could ring the device as if an alarm goes off or if the device gets a call. Then they can swipe away the notification to stop it or something like that, to make sure they saw it. I would choose the sound myself so that it isn't obnoxious.
Is anything like that possible?
yes it's possible but,
you should know the following:
for Android:
1-create a foreground service to keep notification appears to the
restaurants, in this case the restaurant can not hide the
notification.
once the restaurant receive the notification just
sent an event to the foreground service to handle the action and the
data.
start the order activity from foreground service, once the
activity is created just play a sound.
for IOS,
it should be the same but i don't know how to create a foreground service in IOS.

On Oreo, is it possible to mute individual notifications belonging to the same notification channel?

I have a bunch of notifications for new messages (MessagingStyle, one notification contains one or more messages with the same user), and I want to play sound when a new message arrives now. Sometimes I want to update the notification silently, though. For instance:
On system boot up, I want to present old messages to the user without sound
When the application is not connected, I want to update the notifications to remove the “Reply” button, and vice versa
When an application receives a message that was posted some time in the past, I don't want to alert the user as they may have read the message elsewhere.
It works fine on L but Oreo seems to be playing sound for every notification fire or update. Is there a way to work around this behavior?

Mute a specific notification

I am using a Notification Listener Service to receive any posted notification.
For some reason I would like to mute a notification that comes with a specific text. For example, if a Whatsapp notification is posted from a specific contact I may decide to mute that notification or to let it play as normal.
Is there any way to mute it?
I receive many emails from Office and all of them are important and I have to wake up in the night. But sometimes one is not important (the subject in the email is "not urgent") and I don't need to wake up in that case.
I know I can dismiss a notification but I want to let it display. I just want to mute the sound. Any ideas?
I Don't think you can "mute" notification from other apps. Every App works in it's own sandbox so you can't react with an "multi-maintenance-tool" to the apps.
A better Idea is to use an extended e-mail client (like K-9 Email) and check, if there are features like yours in there. Or check other e-mail clients.

Manage SMS Notification sound with Defaut SMS App

I would like to write a simple app which can manage the default SMS notification by assigning a specific sound to a specific user. In my intention this app would only do this (so it's not a complete replacement of SMS app) and let the user handle sms with the default SMS App.
So it simply turns into the ability to override programmatically the sms notification sound when one is received. The notification sound are stored on the SD card. I tried couple ways to obtain this but until now no success:
Using RingtoneManager.setActualDefaultRingtoneUri() inserting tone into ContentResolver leads me to some annoying issues. First when added to database, the new ringtone appears in the sound list and second, once the notification is overridden using RingtoneManager.setActualDefaultRingtoneUri(), I'm not able to roll back to the default notification sound and in particular I don't know WHEN doing it!
Creating a Notification object and using PreferenceManager class but facing similar problems as written above (WHERE override the sound and WHEN doing it).
Thank you all in advance.

Controlling SMS notifications

I have created a broadcast receiver that uses the SMS_RECEIVER. So far everything works fine with it. Now I would like to modify the notification settings for the sms e.g. adjust volume, turn on vibrate, change audio file...
Basically, I would like this app to duplicate the custom ringtone notification. So I would get the sms, check the senders phone number, and change the notification accordingly. I'm having trouble finding documentation on how to do this per text message. Could someone please link me to some documentation or a code snipet of how to do this?
(I found an example on how to silence the phone but the problem with that example is the phone will remain silenced until the code/user turns the volume back on. I would like to only perform the action on the text message being received at the time, this way it will not affect other functionality of the phone)

Categories

Resources