@@ -222,6 +222,7 @@ def apns_send_message(
222
222
loc_key : str = None ,
223
223
priority : int = None ,
224
224
collapse_id : str = None ,
225
+ mutable_content : bool = False ,
225
226
err_func : ErrFunc = None ,
226
227
):
227
228
"""
@@ -238,6 +239,9 @@ def apns_send_message(
238
239
:param alert: The alert message to send
239
240
:param application_id: The application_id to use
240
241
:param creds: The credentials to use
242
+ :param mutable_content: If True, enables the "mutable-content" flag in the payload.
243
+ This allows the app's Notification Service Extension to modify
244
+ the notification before it is displayed.
241
245
"""
242
246
results = apns_send_bulk_message (
243
247
registration_ids = [registration_id ],
@@ -253,6 +257,7 @@ def apns_send_message(
253
257
loc_key = loc_key ,
254
258
priority = priority ,
255
259
collapse_id = collapse_id ,
260
+ mutable_content = mutable_content ,
256
261
err_func = err_func ,
257
262
)
258
263
@@ -277,6 +282,7 @@ def apns_send_bulk_message(
277
282
loc_key : str = None ,
278
283
priority : int = None ,
279
284
collapse_id : str = None ,
285
+ mutable_content : bool = False ,
280
286
err_func : ErrFunc = None ,
281
287
):
282
288
"""
@@ -291,6 +297,9 @@ def apns_send_bulk_message(
291
297
:param alert: The alert message to send
292
298
:param application_id: The application_id to use
293
299
:param creds: The credentials to use
300
+ :param mutable_content: If True, enables the "mutable-content" flag in the payload.
301
+ This allows the app's Notification Service Extension to modify
302
+ the notification before it is displayed.
294
303
"""
295
304
try :
296
305
topic = get_manager ().get_apns_topic (application_id )
@@ -311,6 +320,7 @@ def apns_send_bulk_message(
311
320
loc_key = loc_key ,
312
321
priority = priority ,
313
322
collapse_id = collapse_id ,
323
+ mutable_content = mutable_content ,
314
324
err_func = err_func ,
315
325
))
316
326
@@ -355,12 +365,17 @@ async def _send_bulk_request(
355
365
loc_key : str = None ,
356
366
priority : int = None ,
357
367
collapse_id : str = None ,
368
+ mutable_content : bool = False ,
358
369
err_func : ErrFunc = None ,
359
370
):
360
371
client = _create_client (
361
372
creds = creds , application_id = application_id , topic = topic , err_func = err_func
362
373
)
363
374
375
+ aps_kwargs = {}
376
+ if mutable_content :
377
+ aps_kwargs ["mutable-content" ] = mutable_content
378
+
364
379
requests = [_create_notification_request_from_args (
365
380
registration_id ,
366
381
alert ,
@@ -372,6 +387,7 @@ async def _send_bulk_request(
372
387
loc_key = loc_key ,
373
388
priority = priority ,
374
389
collapse_id = collapse_id ,
390
+ aps_kwargs = aps_kwargs
375
391
) for registration_id in registration_ids ]
376
392
377
393
send_requests = [_send_request (client , request ) for request in requests ]
0 commit comments