I need some hints for the following system:
- client app: Android
- backend: Firebase Cloud Funtions
- database: realtime database
One of the scenarios is as follows:
- All users are on android devices.
Users are sign-in via OAuth2 (google accounts).
- User1 creates an offer and the offer is 'waiting' in active offers list.
- Other users are notified for the change is active offers list..
- User2 requests the offer and the offer is 'requested'
- Other users are notified for the change is active offers list..
- User 1 is notified for the User2's request
User1 confirms/denies the User1's request:
a) confirms and the offer is 'completed' and removed from the active offers list.
b) denies and the offer is again 'waiting' in the active offers list.
- Other users are notified for the change is active offers list..
- User2 is notified for the User1's confirmation/denial
NOTE: System is specific and limited so the active offers list will be short enough and that's why currently I'm thinking about notifying users about list modifications and not about a single offer modification, but I'm open for advices.
==========================================
Currenty I've implemented the following:
User1 creates an offer and the offer is 'waiting':
- android app calls createOffer(...) firebase cloud function
- createOffer(...) adds a new offer to the offers list in realtime database.
- onWrite(...) realtime database trigger is fired on active offers list level
here I need the hint
User2 requests the offer and the offer is 'requested':
- android app calls requestOffer(...) firebase cloud function
- requestOffer(...) modifies the offer in realtime database.
- onWrite(...) realtime database trigger is fired on active offers list level
here I need the hint
here I need the hint
User1 confirms/denies the User1's request:
a) confirmation:
- android app calls confirnOfferRequest(...) firebase cloud function
- confirmOfferRequest(...) removes the offer from active offers list.
- onWrite(...) realtime database trigger is fired on active offers list level
b) denial:
- android app calls denyOfferRequest(...) firebase cloud function
- denyOfferRequest(...) modifies the offer in active offers list. onWrite(...) realtime database trigger is fired on active offers list level.
.
here I need the hint
here I need the hint
==================================
So I need hints about notifications to android application: steps 2, 4, 5, 7, 8
I guess I should use FCM, but:
Android tutorials I find are about the deprecated FirebaseInstanceId
I'm not sure what is my case:
- topic messages
- device groups
- upstream messages
I'm not sure how to notify android app by onWrite(...) realtime database trigger.
Signed-in users only should be notified about active offers list changes. if a user is singed-out should not be notified and when sign-in should get actual state (active offers list).
=============
@James Poag, Thank you for the hints. I'll try and give feedback.
I have some questions:
When I said "notification" I didn't mean 'real' notification in device's 'status bar'. At least current plan is the application to show the info inside itself - this I called "notification". It seems simpler.
- is there a reason to use onCreate() instead of onWrite() ?
Currently my plan is to perform same action on creating/updating an offer so I thought onWrite() would do the trick for both cases. Or not ?
thanks for transaction hint :)
I guess in my case I have "data" messages, not "real" notifications.
I have to read about the permissions. thanks.
Currenty I check for authorization this way:
if (!context.auth) {
return Promise.reject(Error('User is not authenticated.'));
}