我要值添加到蘋果手錶通知(當前屏幕採用硬編碼數據):Apple關注通知載荷
我想補充的值是這些字段:「金額」 ,「At」和「When」。我如何添加從PushNotificationPayload.apns文件中獲取這些值並在通知中顯示它?
這是PushNotificationPayload.apns文件:
{
"aps": {
"alert": {
"body": "New Transaction\n\n",
"title": "Optional title"
},
"category": "newTransactionCategory"
},
"WatchKit Simulator Actions": [
{
"title": "Details",
"identifier": "transactionDetailsButtonAction"
}
],
"customKey": "Use this file to define a testing payload for your notifications. The aps dictionary specifies the category, alert text and title. The WatchKit Simulator Actions array can provide info for one or more action buttons in addition to the standard Dismiss button. Any other top level keys are custom payload. If you have multiple such JSON files in your project, you'll be able to select them when choosing to debug the notification interface of your Watch App."
}
喜@ DH14-S L,我想試試您的解決方案。不過目前我遇到運行自定義長外觀通知的問題。我已經在這裏發佈錯誤:http://stackoverflow.com/questions/29341051/how-to-avoid-this-error-took-too-long-to-show-custom-notification-falling-bac/29345228# 29345228 – user1872384 2015-03-31 07:14:30
確保Storyboard和Payload中的'category'鍵是正確的。然後檢查你是否在'willActivate'上寫了任何長時間運行的代碼。 – Dhawal 2015-03-31 07:37:39
不幸的是,它仍然沒有解決錯誤。 :(即使創建一個新的項目,並設置一個新的watchkit目標與啓用自定義通知也會給這個錯誤以及...這是如此令人沮喪... – user1872384 2015-03-31 07:41:38