Skip to content

Commit 93807af

Browse files
author
cwxia0s
committed
feat: Add call; fix: Sound unavailiable while using call
1 parent 7321006 commit 93807af

File tree

6 files changed

+30
-36
lines changed

6 files changed

+30
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ English | **[中文文档](README.zh.md)**
1010
> There are bugs in Cloudflare Dashboard for now(2024-07-27), deploy and variables edit are not available, DONOT change anything before Cloudflare fix that. If you want to deploy, use wrangler. -->
1111

1212
> [!NOTE]
13-
> On iOS 18, device token may change, the previous way to use multi-key or key alias may be unavailable, refer to [Tips](doc/tips.md) for more details.
13+
> Device token may change, the previous way to use multi-key or key alias may be unavailable, refer to [Tips](doc/tips.md) for more details.
1414
1515
<!-- > [!CAUTION]
1616
> For D1 Alpha Users: On August 1, 2024, D1 alpha databases will stop accepting live SQL queries. See [Migration Guide](https://developers.cloudflare.com/d1/platform/alpha-migration/) -->

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
> Cloudflare Dashboard 目前(2024-07-27)存在Bug, 部署和变量编辑不可用, 在Cloudflare修复该问题之前请勿进行任何操作, 如果需要部署请使用wrangler. -->
1111

1212
> [!NOTE]
13-
> 在iOS 18 Beta 1上观察到device token变化的情况, 之前使用多Key或Key别名的方法可能会失效, 如有多Key使用需要参考[Tips](doc/tips.zh.md).
13+
> Device token可能发生变化, 之前使用多Key或Key别名的方法可能会失效, 如有多Key使用需要参考[Tips](doc/tips.zh.md).
1414
1515
<!-- > [!CAUTION]
1616
> 对于D1 Alpha用户: 在2024-08-01之后, D1 Alpha数据库将停止接受SQL查询,需要使用新的D1数据库,参考[迁移指南](https://developers.cloudflare.com/d1/platform/alpha-migration/) -->

doc/tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Multi Device Key to One Device & Set Key Alias
44

55
> [!NOTE]
6-
> In iOS 18, token may change after a period of time. If you need to use multiple keys or key alias, you can add the same server in your App for multiple times. If you need to use key alias, you can add the same server in your App, then manually set the key alias in database, and then use the reset key function in App to specify the key alias.
6+
> Device token may change after a period of time. If you need to use multiple keys or key alias, you can add the same server in your App for multiple times. If you need to use key alias, you can add the same server in your App, then manually set the key alias in database, and then use the reset key function in App to specify the key alias.
77
88
In KV or D1 Database, Manually Set Records as follow:
99

doc/tips.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 一个设备多个Key或Key别名
44

55
> [!NOTE]
6-
> 在iOS 18上观察到token变化的情况,此方法可能在使用一段时间后失效.如有多Key使用需求,直接在App中添加多次服务器即可.如果需要使用别名,先在App中添加一次服务器,在数据库中手动修改Key为别名,随后在App中使用重置Key功能指定Key别名.
6+
> 设备token可能会随时间变化.如有多Key使用需求,直接在App中添加多次服务器即可.如果需要使用别名,先在App中添加一次服务器,在数据库中手动修改Key为别名,随后在App中使用重置Key功能指定Key别名.
77
88
在KV或D1数据库中, 按如下格式手动修改数据:
99

main.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ async function handleRequest(request, env, ctx) {
128128
*/
129129
class Handler {
130130
constructor(env) {
131-
this.version = "v2.1.2"
132-
this.build = "2024-11-14 20:10:05"
131+
this.version = "v2.1.3"
132+
this.build = "2024-11-22 23:52:47"
133133
this.arch = "js"
134-
this.commit = "8bba6448095f56b0340b2df2af8eb7fbd13a5933"
134+
this.commit = "73210060060f2d073e29ecec7b895a8ab470a6e7"
135135

136136
const db = new Database(env)
137137

@@ -254,16 +254,17 @@ class Handler {
254254
sound += '.caf'
255255
}
256256
const category = parameters.category || 'myNotificationCategory'
257-
const group = parameters.group || 'Default'
258-
257+
const group = parameters.group || undefined
258+
259+
const call = parameters.call || undefined
259260
const isArchive = parameters.isArchive || undefined
260261
const icon = parameters.icon || undefined
261-
const url = parameters.url || undefined
262+
const ciphertext = parameters.ciphertext || undefined
262263
const level = parameters.level || undefined
264+
const url = parameters.url || undefined
263265
const copy = parameters.copy || undefined
264-
const badge = parameters.badge || 0
266+
const badge = parameters.badge || undefined
265267
const autoCopy = parameters.autoCopy || undefined
266-
const ciphertext = parameters.ciphertext || undefined
267268

268269
// https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification
269270
const aps = {
@@ -280,12 +281,8 @@ class Handler {
280281
'loc-key': undefined,
281282
'loc-args': undefined,
282283
},
283-
'badge': 0,
284-
'sound': {
285-
'critical': 0,
286-
'name': sound,
287-
'volume': 1.0,
288-
},
284+
'badge': undefined,
285+
'sound': sound,
289286
'thread-id': group,
290287
'category': category,
291288
'content-available': undefined,
@@ -303,6 +300,7 @@ class Handler {
303300
'attributes': undefined,
304301
},
305302
// ExtParams
303+
'call': call,
306304
'isarchive': isArchive,
307305
'icon': icon,
308306
'ciphertext': ciphertext,
@@ -311,7 +309,6 @@ class Handler {
311309
'copy': copy,
312310
'badge': badge,
313311
'autocopy': autoCopy,
314-
'group': group,
315312
}
316313

317314
const apns = new APNs(db)

main_kv.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ async function handleRequest(request, env, ctx) {
128128
*/
129129
class Handler {
130130
constructor(env) {
131-
this.version = "v2.1.2"
132-
this.build = "2024-11-14 20:10:05"
131+
this.version = "v2.1.3"
132+
this.build = "2024-11-22 23:52:47"
133133
this.arch = "js"
134-
this.commit = "8bba6448095f56b0340b2df2af8eb7fbd13a5933"
134+
this.commit = "73210060060f2d073e29ecec7b895a8ab470a6e7"
135135

136136
const db = new Database(env)
137137

@@ -254,16 +254,17 @@ class Handler {
254254
sound += '.caf'
255255
}
256256
const category = parameters.category || 'myNotificationCategory'
257-
const group = parameters.group || 'Default'
258-
257+
const group = parameters.group || undefined
258+
259+
const call = parameters.call || undefined
259260
const isArchive = parameters.isArchive || undefined
260261
const icon = parameters.icon || undefined
261-
const url = parameters.url || undefined
262+
const ciphertext = parameters.ciphertext || undefined
262263
const level = parameters.level || undefined
264+
const url = parameters.url || undefined
263265
const copy = parameters.copy || undefined
264-
const badge = parameters.badge || 0
266+
const badge = parameters.badge || undefined
265267
const autoCopy = parameters.autoCopy || undefined
266-
const ciphertext = parameters.ciphertext || undefined
267268

268269
// https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification
269270
const aps = {
@@ -280,12 +281,8 @@ class Handler {
280281
'loc-key': undefined,
281282
'loc-args': undefined,
282283
},
283-
'badge': 0,
284-
'sound': {
285-
'critical': 0,
286-
'name': sound,
287-
'volume': 1.0,
288-
},
284+
'badge': undefined,
285+
'sound': sound,
289286
'thread-id': group,
290287
'category': category,
291288
'content-available': undefined,
@@ -303,6 +300,7 @@ class Handler {
303300
'attributes': undefined,
304301
},
305302
// ExtParams
303+
'call': call,
306304
'isarchive': isArchive,
307305
'icon': icon,
308306
'ciphertext': ciphertext,
@@ -311,7 +309,6 @@ class Handler {
311309
'copy': copy,
312310
'badge': badge,
313311
'autocopy': autoCopy,
314-
'group': group,
315312
}
316313

317314
const apns = new APNs(db)
@@ -440,7 +437,7 @@ class Database {
440437
}
441438

442439
this.saveDeviceTokenByKey = async (key, token) => {
443-
const device_token = (key || '').replace(/[^a-z0-9]/g, '') || "_PLACE_HOLDER_"
440+
const device_token = (token || '').replace(/[^a-z0-9]/g, '') || "_PLACE_HOLDER_"
444441
const deviceToken = await kvStorage.put(key, device_token)
445442
return await deviceToken
446443
}
@@ -451,7 +448,7 @@ class Database {
451448
}
452449

453450
this.authorizationToken = async () => {
454-
await kvStorage.get('_authToken_')
451+
return await kvStorage.get('_authToken_')
455452
}
456453
}
457454
}

0 commit comments

Comments
 (0)