This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fcmClient, err := app.Messaging(context.Background()) | |
| if err != nil { | |
| return err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| export default { | |
| setup() { | |
| console.log("I'm setup hook"); | |
| }, | |
| data() { | |
| console.log("I'm data hook"); | |
| return { | |
| stateOfBob: "sleeping", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| mounted() { | |
| console.log("I'm mounted hook"); | |
| console.log("The Dom node is ", this.$refs["greeting"]); | |
| } | |
| </script> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| updated() { | |
| console.log("I'm updated hook"); | |
| this.img = "https://picsum.photos/200/300"; //updates the image src | |
| }, | |
| </script> | |