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
 | 
			
		||||
		if len(req.Message) > 0 {
 | 
			
		||||
			notification.Notification.Body = req.Message
 | 
			
		||||
		}
 | 
			
		||||
		isNotificationSet = true
 | 
			
		||||
		n = req.Notification
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		if len(req.Title) > 0 {
 | 
			
		||||
			notification.Notification.Title = req.Title
 | 
			
		||||
		}
 | 
			
		||||
	if len(req.Message) > 0 {
 | 
			
		||||
		isNotificationSet = true
 | 
			
		||||
		n.Body = req.Message
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		if len(req.Image) > 0 {
 | 
			
		||||
			notification.Notification.Image = req.Image
 | 
			
		||||
		}
 | 
			
		||||
	if len(req.Title) > 0 {
 | 
			
		||||
		isNotificationSet = true
 | 
			
		||||
		n.Title = req.Title
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		if v, ok := req.Sound.(string); ok && len(v) > 0 {
 | 
			
		||||
			notification.Notification.Sound = v
 | 
			
		||||
		}
 | 
			
		||||
	if len(req.Image) > 0 {
 | 
			
		||||
		isNotificationSet = true
 | 
			
		||||
		n.Image = req.Image
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if v, ok := req.Sound.(string); ok && len(v) > 0 {
 | 
			
		||||
		isNotificationSet = true
 | 
			
		||||
		n.Sound = v
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if isNotificationSet {
 | 
			
		||||
		notification.Notification = n
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// handle iOS apns in fcm
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue