@@ -89,11 +89,13 @@ class Notification(object):
8989 Args:
9090 title: Title of the notification (optional).
9191 body: Body of the notification (optional).
92+ image: Image url of the notification (optional)
9293 """
9394
94- def __init__ (self , title = None , body = None ):
95+ def __init__ (self , title = None , body = None , image = None ):
9596 self .title = title
9697 self .body = body
98+ self .image = image
9799
98100
99101class AndroidConfig (object ):
@@ -153,11 +155,12 @@ class AndroidNotification(object):
153155 title_loc_args: A list of resource keys that will be used in place of the format specifiers
154156 in ``title_loc_key`` (optional).
155157 channel_id: channel_id of the notification (optional).
158+ image: Image url of the notification (optional).
156159 """
157160
158161 def __init__ (self , title = None , body = None , icon = None , color = None , sound = None , tag = None ,
159162 click_action = None , body_loc_key = None , body_loc_args = None , title_loc_key = None ,
160- title_loc_args = None , channel_id = None ):
163+ title_loc_args = None , channel_id = None , image = None ):
161164 self .title = title
162165 self .body = body
163166 self .icon = icon
@@ -170,6 +173,7 @@ def __init__(self, title=None, body=None, icon=None, color=None, sound=None, tag
170173 self .title_loc_key = title_loc_key
171174 self .title_loc_args = title_loc_args
172175 self .channel_id = channel_id
176+ self .image = image
173177
174178
175179class AndroidFCMOptions (object ):
@@ -419,10 +423,13 @@ class APNSFCMOptions(object):
419423 Args:
420424 analytics_label: contains additional options for features provided by the FCM iOS SDK
421425 (optional).
426+ image: contains the URL of an image that is going to be displayed in a notification
427+ (optional).
422428 """
423429
424- def __init__ (self , analytics_label = None ):
430+ def __init__ (self , analytics_label = None , image = None ):
425431 self .analytics_label = analytics_label
432+ self .image = image
426433
427434
428435class FCMOptions (object ):
@@ -600,6 +607,9 @@ def encode_android_notification(cls, notification):
600607 'AndroidNotification.title_loc_key' , notification .title_loc_key ),
601608 'channel_id' : _Validators .check_string (
602609 'AndroidNotification.channel_id' , notification .channel_id ),
610+ 'image' : _Validators .check_string (
611+ 'image' , notification .image
612+ )
603613 }
604614 result = cls .remove_null_values (result )
605615 color = result .get ('color' )
@@ -754,6 +764,7 @@ def encode_apns_fcm_options(cls, fcm_options):
754764 result = {
755765 'analytics_label' : _Validators .check_analytics_label (
756766 'APNSFCMOptions.analytics_label' , fcm_options .analytics_label ),
767+ 'image' : _Validators .check_string ('APNSFCMOptions.image' , fcm_options .image )
757768 }
758769 result = cls .remove_null_values (result )
759770 return result
@@ -851,13 +862,15 @@ def encode_aps_alert(cls, alert):
851862
852863 @classmethod
853864 def encode_notification (cls , notification ):
865+ """Encodes an Notification instance into JSON."""
854866 if notification is None :
855867 return None
856868 if not isinstance (notification , Notification ):
857869 raise ValueError ('Message.notification must be an instance of Notification class.' )
858870 result = {
859871 'body' : _Validators .check_string ('Notification.body' , notification .body ),
860872 'title' : _Validators .check_string ('Notification.title' , notification .title ),
873+ 'image' : _Validators .check_string ('Notification.image' , notification .image )
861874 }
862875 return cls .remove_null_values (result )
863876
0 commit comments