Skip to content

Instantly share code, notes, and snippets.

View nidhi-canopas's full-sized avatar

nidhi-canopas

View GitHub Profile
fcmClient, err := app.Messaging(context.Background())
if err != nil {
return err
}
response, err := fcmClient.Send(context.Background(), &messaging.Message{
Notification: &messaging.Notification{
Title: "Congratulations!!",
Body: "You have just implement push notification",
},
Token: "sample-device-token", // it's a single device token
})
if err != nil {
response, err := fcmClient.SendMulticast(context.Background(), &messaging.MulticastMessage{
Notification: &messaging.Notification{
Title: "Congratulations!!",
Body: "You have just implemented push notification",
},
Tokens: deviceTokens, // it's an array of device tokens
})
if err != nil {
return err
func SendPushNotification(deviceTokens []string) error {
decodedKey, err := getDecodedFireBaseKey()
if err != nil {
return err
}
opts := []option.ClientOption{option.WithCredentialsJSON(decodedKey)}
app, err := firebase.NewApp(context.Background(), nil, opts...)
<script>
export default {
setup() {
console.log("I'm setup hook");
},
data() {
console.log("I'm data hook");
return {
stateOfBob: "sleeping",
<script>
created() {
console.log("I'm created hook");
console.log("Bob is currently ", this.stateOfBob);
this.stateOfBob = "awakened but still sleeping";
console.log("Bob is currently ", this.stateOfBob);
console.log("computed hook is returning ", this.test);
}
<template>
<div ref="greeting">Hello readers !</div>
</template>
<script>
beforeMount() {
console.log("I'm beforeMount hook");
console.log("The Dom node is ", this.$refs["greeting"]);
},
</scrip>
<script>
mounted() {
console.log("I'm mounted hook");
console.log("The Dom node is ", this.$refs["greeting"]);
}
</script>
<template>
<img ref="img" :src="img" alt="image" width="200" />
<span>comment/uncomment me to see beforeUpdate/updated hook's reactivity</span>
</template>
<script>
export default {
data() {
console.log("I'm data hook");
return {
<script>
updated() {
console.log("I'm updated hook");
this.img = "https://picsum.photos/200/300"; //updates the image src
},
</script>