-
-
Notifications
You must be signed in to change notification settings - Fork 0
Data Models
Rutvik Tak edited this page Oct 26, 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: // any ref image for this notification
String Type: // type of notification
// Type - twitter
String Tweetid: $tweetId,
// Type - streams
String YoutubeId: $youtubeVideoId,
String ChannelId: $ChannelId, // we were thinking of passing the channel name, profile pic and video title and description along with channelId, tbd
// Type - chase
String Id: $chase doc Id,
// Type - event
This one and other types are need tbd.
String "Interest": //interest name,
// if sending the whole chase data, then pass it like this
"Chase":{
"Id"://chaseId
// other chase details
}
}
}
Notification Document schema stored in this single notifications collection when any Notification is sent
{
String Interest,// interest name
String Title,
String Body,
TimeStamp CreatedAt,
String Type, // notification type
// Schema for this `Data` will be same as the "data" schema sent in notification from firebase/pusher except the Interest
// can be dropped here as we already pass that above.
Map<String, dynamic>? Data : {
String? Image: // any ref image for this notification
String Type: // type of notification
// Type - twitter
String Tweetid: $tweetId,
Map<String,dynamic>? tweetData : {
String tweetId,
String text,
String userId,
String userName,
String name,
String profileImageUrl,
}
// Type - streams
String YoutubeId: $youtubeVideoId,
String ChannelId: $ChannelId,// we were thinking of passing the channel name, profile pic and video title and description along with channelId, tbd
// Type - chase
String Id: $chase_doc_Id,
// Type - event
This one and other types are need tbd.
},
}
Firehose Feed: Firehose Document schema stored in getStream firehose feed when any Notification is sent.
{
String eventType,// notification types as [here](https://github.com/chase-app/flutter/wiki/Notifications)
int created_at,
// Payload defined in the feed dock, i don't remember if this is referred to as payload in their api while setting up or just `data`.
// Check from how ur setting up/naming `payload` for twitter documents for firehose feed.
Map<String, dynamic>? payload : {
String? title: // title
String? body: // description
String? image_url: // ref image
int created_at: // I think this is created by getStream itself for every document or so. Leku just check this once. This is required.
String id: // It can be either chase doc id, tweet id, youtube channel id or any other id based on a type of notification
// Following are data fields mentioned which are needed according to notification type
// twitter type
String name: // name of the twitter user
String text: // description of the tweet
String id: // tweet id
String username: // twitter user username
String image_url: // profile image
// chase type
String id: // chase doc id in firebase
String image_url: // chase imageurl
// stream type
String id: // youtube stream/video id
String channelId: // youtube channel id
String image_url: // stream image if any imageurl
String name: // name of the youtube channel
String text: // description of the video/stream
String username: // channel username
String image_url: // profile image
int subcribersCount: // channels subscribers count
},
}
# [Interests](https://console.firebase.google.com/u/0/project/chaseapp-staging/firestore/data/~2Finterests~2FInOnl50777a1f9sFWrwc)
We'll be managing addition of interests through Firebase.
```DART
{
String id,// doc id
String instanceId,
String name,// interest name
bool isCompulsory, // if true then next time user opens app he'll be subscribed to this interest but he can't disable/unsubscribe it in
// notifications settings
bool isDefault, // if true then next time user opens app he'll be subscribed to this interest but he can disable/unsubscribe it if he want // in notifications settings
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"`
}