@@ -89,11 +89,13 @@ class Notification(object):
89
89
Args:
90
90
title: Title of the notification (optional).
91
91
body: Body of the notification (optional).
92
+ image: Image url of the notification (optional)
92
93
"""
93
94
94
- def __init__ (self , title = None , body = None ):
95
+ def __init__ (self , title = None , body = None , image = None ):
95
96
self .title = title
96
97
self .body = body
98
+ self .image = image
97
99
98
100
99
101
class AndroidConfig (object ):
@@ -153,11 +155,12 @@ class AndroidNotification(object):
153
155
title_loc_args: A list of resource keys that will be used in place of the format specifiers
154
156
in ``title_loc_key`` (optional).
155
157
channel_id: channel_id of the notification (optional).
158
+ image: Image url of the notification (optional).
156
159
"""
157
160
158
161
def __init__ (self , title = None , body = None , icon = None , color = None , sound = None , tag = None ,
159
162
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 ):
161
164
self .title = title
162
165
self .body = body
163
166
self .icon = icon
@@ -170,6 +173,7 @@ def __init__(self, title=None, body=None, icon=None, color=None, sound=None, tag
170
173
self .title_loc_key = title_loc_key
171
174
self .title_loc_args = title_loc_args
172
175
self .channel_id = channel_id
176
+ self .image = image
173
177
174
178
175
179
class AndroidFCMOptions (object ):
@@ -419,10 +423,13 @@ class APNSFCMOptions(object):
419
423
Args:
420
424
analytics_label: contains additional options for features provided by the FCM iOS SDK
421
425
(optional).
426
+ image: contains the URL of an image that is going to be displayed in a notification
427
+ (optional).
422
428
"""
423
429
424
- def __init__ (self , analytics_label = None ):
430
+ def __init__ (self , analytics_label = None , image = None ):
425
431
self .analytics_label = analytics_label
432
+ self .image = image
426
433
427
434
428
435
class FCMOptions (object ):
@@ -600,6 +607,9 @@ def encode_android_notification(cls, notification):
600
607
'AndroidNotification.title_loc_key' , notification .title_loc_key ),
601
608
'channel_id' : _Validators .check_string (
602
609
'AndroidNotification.channel_id' , notification .channel_id ),
610
+ 'image' : _Validators .check_string (
611
+ 'image' , notification .image
612
+ )
603
613
}
604
614
result = cls .remove_null_values (result )
605
615
color = result .get ('color' )
@@ -754,6 +764,7 @@ def encode_apns_fcm_options(cls, fcm_options):
754
764
result = {
755
765
'analytics_label' : _Validators .check_analytics_label (
756
766
'APNSFCMOptions.analytics_label' , fcm_options .analytics_label ),
767
+ 'image' : _Validators .check_string ('APNSFCMOptions.image' , fcm_options .image )
757
768
}
758
769
result = cls .remove_null_values (result )
759
770
return result
@@ -851,13 +862,15 @@ def encode_aps_alert(cls, alert):
851
862
852
863
@classmethod
853
864
def encode_notification (cls , notification ):
865
+ """Encodes an Notification instance into JSON."""
854
866
if notification is None :
855
867
return None
856
868
if not isinstance (notification , Notification ):
857
869
raise ValueError ('Message.notification must be an instance of Notification class.' )
858
870
result = {
859
871
'body' : _Validators .check_string ('Notification.body' , notification .body ),
860
872
'title' : _Validators .check_string ('Notification.title' , notification .title ),
873
+ 'image' : _Validators .check_string ('Notification.image' , notification .image )
861
874
}
862
875
return cls .remove_null_values (result )
863
876
0 commit comments