fix fcm notification (#474)
* fix fcm notification * fix fcm notification for unit test Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
cde026d9f9
commit
cbab088ed4
|
@ -60,25 +60,35 @@ func GetAndroidNotification(req PushNotification) *fcm.Message {
|
|||
}
|
||||
}
|
||||
|
||||
notification.Notification = req.Notification
|
||||
|
||||
n := &fcm.Notification{}
|
||||
isNotificationSet := false
|
||||
if req.Notification != nil {
|
||||
// Set request message if body is empty
|
||||
isNotificationSet = true
|
||||
n = req.Notification
|
||||
}
|
||||
|
||||
if len(req.Message) > 0 {
|
||||
notification.Notification.Body = req.Message
|
||||
isNotificationSet = true
|
||||
n.Body = req.Message
|
||||
}
|
||||
|
||||
if len(req.Title) > 0 {
|
||||
notification.Notification.Title = req.Title
|
||||
isNotificationSet = true
|
||||
n.Title = req.Title
|
||||
}
|
||||
|
||||
if len(req.Image) > 0 {
|
||||
notification.Notification.Image = req.Image
|
||||
isNotificationSet = true
|
||||
n.Image = req.Image
|
||||
}
|
||||
|
||||
if v, ok := req.Sound.(string); ok && len(v) > 0 {
|
||||
notification.Notification.Sound = v
|
||||
isNotificationSet = true
|
||||
n.Sound = v
|
||||
}
|
||||
|
||||
if isNotificationSet {
|
||||
notification.Notification = n
|
||||
}
|
||||
|
||||
// handle iOS apns in fcm
|
||||
|
|
Loading…
Reference in New Issue