android: post / dm handoff from push #4395
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
extends #4280 to Android
This work was complicated by our custom Android notification handling code. Notably, we are intercepting notifications before expo-notifications has a chance to handle them, which I think means that we can't rely on expo-notifications' guarantees when receiving events or accessing notifications via JS (this is backed up by missing fields in the expo-notifications JS payloads, as if expo-notifications didn't have a chance to add the expected
trigger
data before JS could consume it).more details about how we're breaking expo-notification's guarantees
I'm new to Android notifications, but here's my understanding:
tlon-apps/apps/tlon-mobile/android/app/src/main/AndroidManifest.xml
Lines 23 to 27 in 686ba3a
FirebaseMessagingService
tlon-apps/apps/tlon-mobile/android/app/src/main/java/io/tlon/landscape/TalkMessagingService.java
Line 14 in 686ba3a
FirebaseMessagingService
class and callsuper
on each event, then append our behavior after they did their workFirebaseMessagingService
a couple of years ago [expo-notifications] Extract Firebase managing responsibility to a composite of the central service expo/expo#10558 so we'd need to change to use this kind of service (?) to ingest notifications. I gave this a shot, but I had trouble moving our Android code to this kind of service. I think it'd still be possible and what we should do.Summary
post
/dmPost
notification payloads that iOS adds (added inline comments about complications), so I put this data as JSON strings in the notification payload on AndroidNotificationRequest.trigger
on Android – expo-notifications' types says thistrigger
should never be null, but it is null on Android. This could either be an issue within expo-notifications (I didn't find anything in their issues in a quick search), or it could be due to how we manipulate notifications, which goes against expo-notifications' recommendation. To quickfix, I added cases to handle a nulltrigger
to avoid crash.To fix, hold off on clearing notifications unless we have an active session.
How did I test?