I'm an iOS app developer and not familiar with Android. I'd like to implement the feature that playbacks audio over the internet when the mobile receives a push notification.
I've investigated it for iOS and concluded that it is impossible in iOS because Apple prohibits downloading data over the internet in background from being developed.
I'd like to know if this feature is feasible or not in Android. Could you give me any advises ?
You need to implement PendingIntent to get you notification and start ForgroundService or this or this to play your audio and close it when the user leaves your app or while they are using your app depending your particular needs.
Related
I am working on an Ionic app, that connects with websocket server and when the app receives new message I want to play audio in a loop till user reacts to it.
All of that works when the app is open. When the app is in the background (or the phone is locked), the sound is not played (either this or the message is not received at all).
Basically, I want similar behaviour to the Meta's Messanger app.
How can I achieve that? I guess I lack some basic mobile app development knowledge, because I do backend on daily basis.
I am developing it for Android.
Currently I am using twilio video for video calls from mobile to mobile. I am using FCM push notifications to start calls. Is there a better way using a real-time way to handle calls between devices. Just looking for better reliability since push notifications can be inconsistent.
Not exactly sure how real-time would work with app in background/closed when starting calls.
I think make it a background service so that it runs unless the user terminates the app
Twilio developer evangelist here.
On iOS you can use CallKit to create push notifications that behave like an incoming call. The Twilio Video iOS Quickstarts repo has an example Twilio Video CallKit application you can look into.
I'm afraid I don't know of a better way to do this with Android though.
I am creating a native social app which includes features such as Direct Messages, Voice and Video Calls etc and I have been trying to find a way to be able to receive data payloads from Firebase Cloud Messaging containing values such that I create a custom notification based on the type values from the data payload eg for VOIP calls I’d like to set a remoteInput action to see if a person declines or accepts a call or for direct messages add a remoteInput action for a quick reply and so far I haven’t had any luck especially with background services not being allowed anymore ever since the release of Android 8.1. So I would like to know if there’s a workaround I’ve been missing or if it’s even possible and if it is how do these popular apps do it. Thank you in advance.
Its same as your mentioned, once after the release of 8.1 apps are now more strict in regarding the background running process. There are actually two insights I had received while developed some projects. 1) More the app is used by the user, the app is sort of whitelisted and can receive more notifications, i.e., the system actually tracks the frequency of app usage. 2) You have the possibility to ignore your app from battery optimization process hence more chance of background process to run.
We have been trying for the last two weeks to get a reliable solution to try and sync our app data with a server in the background. We have tried the Background fetch mechanism but due to the iOS restrictions on when it runs it is not a viable solution.
iOS does provide Remote Notifications (https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app?language=objc) that we would like to use as we can use the same mechanism on Android.
The issues is that when sending a type 2 notification CN1 only delivers the notification when the app is brought to the foreground by the user.
On Android I see there is a Build Hint for android.background_push_handling that allows the notifications to be sent to the app even if it is in the background.
Is there a similar build hint that we can use for iOS?
If not, is there a way then to override the application:didReceiveRemoteNotification:fetchCompletionHandler: method that fires when the Notification arrives so that we can forward it to our app?
You can use silent push notifications for that purpose. To send a silent push notification you just have to include "content-available" : 1" into the body of the notification. More info on that here: Apple docs-silent push notifications
You should bear in mind that this will only work when your app is in the background, it won't work when the app is killed. When the app is killed the only solution is standard push notifications, unless your app has VoIP functionality, in which case you are allowed to use PushKit framework (if you use it in an app without VoIP functionality, you won't get pass the AppStore).
This question already has answers here:
Open app on firebase notification received (FCM)
(4 answers)
Closed 5 years ago.
I'm developing a WebRTC app with React Native. I've got Firebase working, and I can receive notifications on my Android/iOS devices whilst in the background or foreground.
Is there any way of when I receive a push-notification to automatically open the app for me, without requiring the user input?
Thanks in advance.
If you are going for the scenario of an incoming call, it's not the same for both platforms.
For Android, you can start an activity responding to a push notification, but iOS doesn't allow that. You can either send a regular push notification the user might miss, or use CallKit and integrate it with your stuffs.
Unfortunately I don't know good libraries for React Native that can help you with that yet, so it might have to be done natively and bridged to your RN code.
Edit:
Android example - In your native code handling a notification, you can use context.startActivity(launchIntent); to launch your app with an incoming call screen.
Sorry to deviate a little from the code perspective.
But if you are looking forward for external triggers, I would recommend MacroDroid as a potential solution. There are numerous triggers including Notification reads, SMS etc., Macrodroid is available in Play store with trial version limited to five macros per user. Logical validations, loops and much more features to explore.