iOS 推送通知:iOS 日志 "NOT delivering non-notifying push notification"

iOS push notifications: iOS logs "NOT delivering non-notifying push notification"

为什么 iOS 没有向我的设备发送推送通知?

我正在使用 curl 发送推送通知,如下所示:

curl -v \
--http2 \
--header "apns-push-type: alert" \
--header "apns-priority: 10" \
--header "authorization: bearer $jwt" \
--header "apns-topic: ${BUNDLEID}" \
--data '{"aps": {"content-available": 1, "interruption-level": "active"}, "alert": {"title":"title", "body": "body"}}' \
"${URL}"

不幸的是,当我查看 Console.app 时,我看到日志:

[uk.orth.pushExampleTemporary] Received remote notification request FDCA-F040 [ waking: 0, hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 pushType: Alert]

[uk.orth.pushExampleTemporary] NOT requesting DUET deliver content-available, non-notifiying push notification FDCA-F040 [pushType: Alert willNotifyUser: 0]
[uk.orth.pushExampleTemporary] NOT delivering non-notifying push notification FDCA-F040 [pushType: Alert willNotifyUser: 0]

JSON结构问题

我注意到我将数据有效负载设置得有些许错误,这是由于我使用 bash 格式化我的有效负载而不是编程语言类型造成的。

包含有效负载 (--data) 的行应如下所示:

--data '{"aps": {"content-available": 1, "alert": {"title":"title", "body": "body"}}}' \

以后避免这个问题

我已经转向使用 json 文件 (ios_alert_message.json) 来避免这些类型的错误,使用 curl 命令:

curl -v \
--http2 \
--header "apns-push-type: alert" \
--header "apns-priority: 10" \
--header "authorization: bearer $jwt" \
--header "apns-topic: ${BUNDLEID}" \
--header "Content-Type: application/json" \
--data @"$CURRENT_DIR/ios_alert_message.json" \
"${URL}"