-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you process push notifications received while the app is in the background? #351
Comments
Hi @Osmosis311 apologies for the delay! The documentation for adding a NotificationServiceExtension is an iOS-specific step. There is no equivalency on Android that can be exploited by the Xamarin SDK. Note I believe there is a path where you can create an Android native NotificationServiceExtension,it would be written in Java/Kotlin and would extend the Staying within the Xamarin SDK, you are limited to the Please let me know if you have any follow up questions. Thanks! |
@Osmosis311 would you be able to share your use case for why you need to receive control when receiving a notification and your app isn't in the foreground? |
Yes. Critical notifications. If the user has their phone completely
silenced, for specific types of critical alerts, I need to be able to run
code when a notification is received and my app isn’t in the foreground
that utilizes MediaManager to play a sound to get the users attention (this
is of course with their consent. The use case here is volunteer emergency
responders. For example, they may be in an office setting and don’t want to
be disturbed except for emergencies happening nearby).
I think I figured it out, though. I registered a (generic) notification
receiver and that seems to be working exactly the way I want.
…On Tue, Jan 17, 2023 at 10:15 AM Brian Smith ***@***.***> wrote:
@Osmosis311 <https://github.com/Osmosis311> would you be able to share
your use case for why you need to receive control when receiving a
notification *and* your app isn't in the foreground?
—
Reply to this email directly, view it on GitHub
<#351 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACX6MEOAWWICQGKPXUP6FLWS2ZS3ANCNFSM6AAAAAATBL2ANI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
thanks for the feedback @Osmosis311, I'll pass that along internally as a scenario to account for. Yes a generic notification receiver would work as well good thought. If you're up for it please post a version of what you did here and I can try to incorporate it as a solution into our docs. |
I need that badly too. @Osmosis311, your solution would be very helpful. :) |
Here's the code for the receiver. Add this to MainActivity.cs in the
|
Awesome, it works. Thank you. I had it similar, I only registered the receiver in the launch activity and not in main :D |
How can we help?
Is there a way to receive an event / handle a push notification that's received when my app is in the background? I'm using the OneSignal Xamarin SDK, and in the documentation it says to add a notification service extension, and inherit from this class
OSRemoteNotificationReceivedHandler
, but that class isn't found anywhere in the SDK.Is there a way to do this in the Xamarin SDK?
Code of Conduct
The text was updated successfully, but these errors were encountered: