1313 string_types = (str , unicode )
1414
1515
16- def notification (alert = None , ios = None , android = None , winphone = None ):
16+ def notification (alert = None , ios = None , android = None , winphone = None , hmos = None ):
1717 """Create a notification payload.
1818
1919 :keyword alert: A simple text alert, applicable for all platforms.
2020 :keyword ios: An iOS platform override, as generated by :py:func:`ios`.
2121 :keyword android: An Android platform override, as generated by :py:func:`android`.
2222 :keyword winphone: A MPNS platform override, as generated by :py:func:`mpns`.
23+ :keyword hmos: A hmos platform override, as generated by :py:func:`hmos`.
2324
2425 """
2526 payload = {}
@@ -31,6 +32,8 @@ def notification(alert=None, ios=None, android=None, winphone=None):
3132 payload ['android' ] = android
3233 if winphone is not None :
3334 payload ['winphone' ] = winphone
35+ if hmos is not None :
36+ payload ['hmos' ] = hmos
3437 if not payload :
3538 raise ValueError ("Notification body may not be empty" )
3639 return payload
@@ -48,6 +51,9 @@ def ios(alert=None, badge='+1', sound=None, content_available=False,
4851 :keyword extras: A set of key/value pairs to include in the push payload
4952 sent to the device.
5053 :keyword sound_disalbe: Disable sound to implement slient push.
54+ :keyword mutable_content: If True, enables modifying notification content in iOS service extension.
55+ :keyword category: String category for iOS notification action buttons.
56+ :keyword thread_id: String identifier to group related notifications in iOS.
5157
5258 >>> ios(alert='Hello!', sound='cat.caf',
5359 ... extras={'articleid': '12345'})
@@ -147,6 +153,38 @@ def winphone(alert, title=None, _open_page=None, extras=None):
147153 payload ['extras' ] = extras
148154 return payload
149155
156+ def hmos (alert , title = None , category = None , large_icon = None , intent = None , extras = None , style = None , inbox = None ):
157+ """Hmos specific platform override payload.
158+ more info:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#hmos
159+
160+ :keyword alert: String alert text.
161+ :keyword title: String
162+ :keyword category: String
163+ :keyword large_icon: String
164+ :keyword intent: A set of key/value pairs to include in the push payload
165+ :keyword extras: A set of key/value pairs to include in the push payload
166+ :keyword style: String
167+ :keyword inbox: String
168+ """
169+ payload = {}
170+ if alert is not None :
171+ payload ['alert' ] = alert
172+ if title is not None :
173+ payload ['title' ] = title
174+ if category is not None :
175+ payload ['category' ] = category
176+ if large_icon is not None :
177+ payload ['large_icon' ] = large_icon
178+ if intent is not None :
179+ payload ['intent' ] = intent
180+ if extras is not None :
181+ payload ['extras' ] = extras
182+ if style is not None :
183+ payload ['style' ] = style
184+ if inbox is not None :
185+ payload ['inbox' ] = inbox
186+ return payload
187+
150188def message (msg_content , title = None , content_type = None , extras = None ):
151189 """Inner-conn push message payload creation.
152190
@@ -199,7 +237,7 @@ def platform(*types):
199237 if len (types ) == 1 and types [0 ] == 'all' :
200238 return 'all'
201239 for t in types :
202- if t not in ('ios' , 'android' , 'winphone' ):
240+ if t not in ('ios' , 'android' , 'winphone' , 'hmos' ):
203241 raise ValueError ("Invalid platform '%s'" % t )
204242 return [t for t in types ]
205243
0 commit comments