Skip to content
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

Add missing onBackgroundPushReceived method #426

Conversation

MaximBelov
Copy link
Contributor

@MaximBelov MaximBelov commented Apr 19, 2024

What do these changes do?

Add missing onBackgroundPushReceived method

Why are these changes necessary?

How did you verify these changes?

Added method to Example/index,html

Verification Screenshots:

Anything else a reviewer should know?

@MaximBelov MaximBelov changed the title WIP Android Cold start and background mode handle notifications Add missing onBackgroundPushReceived method Apr 19, 2024
@MaximBelov MaximBelov marked this pull request as ready for review April 19, 2024 11:09
@MaximBelov MaximBelov requested a review from a team as a code owner April 19, 2024 11:09
@@ -377,6 +377,11 @@ airship.push.onPushReceived = function (callback) {
return registerListener("airship.event.push_received", callback)
}

airship.push.onBackgroundPushReceived = function (callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only different on Android because on the other frameworks you have to do some special hoops to get background push working. On cordova I am not sure I see a point of separating them. What if we have both airship.event.background_push_received and airship.event.push_received go to the same listener?

Copy link
Contributor Author

@MaximBelov MaximBelov Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on the state of the application in the background only one will work
I added listeners for events

airship.event.push_received - foreground, ios and android
airship.event.notification_response - background, ios only
airship.event.background_push_received - background android only - background or cold start

my initial testing with positive results
it works correctly without any problems

Copy link
Contributor

@rlepinski rlepinski Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do you need it separated? The event map, I think we can just map the background event to airship.event.push_received on Android to have a single onPushReceived. I am not sure if there is a reason to have it broken out on Android.

I might need to modify the proxy to put them all under the same event queue that way the events stay in order https://github.com/urbanairship/airship-mobile-framework-proxy/blob/main/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/EventEmitter.kt#L21

I am thinking ill add a config flag to the proxy to treat all push received as the same thing on Android then we can ignore the background_push_received events.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can combine this into one event listener, but we must add new properties to the response to understand exactly what type of event received and where it came from

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need this exposed in the app?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you will get a foreground on the response but not currently the push received event. We could add it though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds isForeground and orders events - urbanairship/airship-mobile-framework-proxy#39

Going to open a new PR that combines pushReceived and notificationResponses into the same listener

@rlepinski
Copy link
Contributor

#428 still need the proxy to be reviewed + released before the event order is correct and we get the isForeground flag in the events

@MaximBelov
Copy link
Contributor Author

Fixed
#428

@MaximBelov MaximBelov closed this Apr 20, 2024
@MaximBelov MaximBelov deleted the handle-notification-from-cold-start branch April 20, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants