-
-
Notifications
You must be signed in to change notification settings - Fork 0
Data Models
RutvikTak edited this page Mar 4, 2022
·
18 revisions
type ChatMessage struct {
Message string
PhotoURL string
SendDate Time.time
Type string
UID string
User string
}
x? = can be null
{
notification:{
String? title,
String? body,
String? image, // update image parameter as per platform to display image in notifications tray
},
data:{
String? "image" //this image field is used within app,
String? "interest": //interest name,
// if it's a Chase notification then pass the chaseId to id
String? "id"://chaseId
// if sending the whole chase data, then pass it like this
"chase":{
"id"://chaseId
// other chase details
}
}
}
Notification Document schema stored for each User in this single notifications collection when any Notification is sent
{
String interest,// interest name
String? id,// notification doc id
String uid, // user unique id
String? title,
String? body,
String? image,
TimeStamp? createdAt,
// Schema for this `data` will be same as the data schema sent in notification from firebase/pusher except the image and interest
// can be dropped here as we already pass them above.
Map<String, dynamic>? data,
}
We'll be managing addition of interests through Firebase.
{
String id,// doc id
String instanceId,
String name,// interest name
bool isCompulsory,
DateTime createdAt,
}
Some of the ways in which it will help :
- No need to push update when we want to add/update/delete interest streams in our application.
How does it work?
- We add new interest doc in interests collection. Add required data for it.
- App fetches this interests.
- Checks if any one of them isCompulsory notification like "Chases" notifications streams and if yes then adds it to users device interests.
- User sees all of the notifications streams from his interests in the NotificationsView.
- In the settings, user can enable/disable notification streams from interests which are not compulsory.
- Chases notifications take the user to chase details view.
- All other notifications show user a Dialog with notification title, body, image.
type Notification struct {
Name string
Desc string
ImageURL string
URL string
}
type Tags struct {
Name []string
}
type Networks struct {
Name string
URL string
Tier int
Logo string
Other string
}
type Wheels struct {
W1 string
W2 string
W3 string
W4 string
}
type Sentiment struct {
Magnitude float64 `firestore:"magnitude"`
Score float64 `firestore:"score"`
}
type Chase struct {
ID string ""
Name string `firestore:"Name"`
Desc string `firestore:"Desc"`
Live bool `firestore:"Live"`
Networks []Networks `firestore:"Networks"`
Wheels Wheels `firestore:"Wheels"`
Votes int `firestore:"Votes"`
CreatedAt time.Time `firestore:"CreatedAt"`
EndedAt time.Time `firestore:"EndedAt"`
ImageURL string `firestore:"ImageURL"`
Reddit string `firestore:"Reddit"`
Sentiment Sentiment
Tags Tags
}
type PushTokens struct {
Token string `json:"token"`
CreatedAt time.Time `json:"created_at"`
TokenType string `json:"type"`
}
type User struct {
UID string `firestore:"uid"`
LastUpdated time.Time `firestore:"lastupdated"`
PhotoURL string `firestore:"photourl"`
UserName string `firestore:"username"`
Tokens []PushTokens `firestore:"tokens"`
}