Skip to content

Commit 7475d24

Browse files
committed
feat(push): add prod parameter
related ticket: 23600
1 parent 64be716 commit 7475d24

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

leancloud/push.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def send(
4747
where=None,
4848
cql=None,
4949
flow_control=None,
50+
prod=None,
5051
):
5152
"""
5253
发送推送消息。返回结果为此条推送对应的 _Notification 表中的对象,但是如果需要使用其中的数据,需要调用 fetch() 方法将数据同步至本地。
@@ -67,6 +68,8 @@ def send(
6768
:rtype: Notification
6869
:param flow_control: 不为 None 时开启平滑推送,值为每秒推送的目标终端用户数。开启时指定低于 1000 的值,按 1000 计。
6970
:type: flow_control: int
71+
:param prod: 仅对 iOS 推送有效,设置将推送发至 APNs 的开发环境(dev)还是生产环境(prod)。
72+
:type: prod: string
7073
"""
7174
if expiration_interval and expiration_time:
7275
raise TypeError("Both expiration_time and expiration_interval can't be set")
@@ -75,8 +78,11 @@ def send(
7578
"data": data,
7679
}
7780

78-
if client.USE_PRODUCTION == "0":
79-
params["prod"] = "dev"
81+
if prod is None:
82+
if client.USE_PRODUCTION == "0":
83+
params["prod"] = "dev"
84+
else:
85+
params["prod"] = prod
8086

8187
if channels:
8288
params["channels"] = channels

tests/test_push.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_basic_push(): # type: () -> None
4646
where=query,
4747
push_time=now,
4848
expiration_time=two_hours_later,
49+
prod="dev",
4950
flow_control=0,
5051
)
5152
# flow_control = 0 <=> flow_control = 1000 by rest api design

0 commit comments

Comments
 (0)