我正在使用OneSignal来管理我的推送通知。对于某些通知,我收到以下信息:
我缺少什么?非常感谢您的帮助。
但是我只有用英语发送所有内容...通知必须有英语内容
oneSignal.postNotification(["headings" : ["en": "\(who)"],
"subtitle" : ["en": "\(subtitle)"],
"contents" : ["en": "\(contents)"],
"include_player_ids": [result]],
谁、副标题和内容是字符串,结果是接收方ID。大多数通知已发送,但有些我收到了错误消息。
控制台:
> ERROR: Create notification failed
Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
errors = (
" Notifications must have English language content"
);
}}
我的完整函数:
func sendPush(_ receiverID: String, _ who: String, _ didWhat: String, _ message: String?) {
var subtitle = ""
var contents = ""
if message != nil {
contents = message!
}
switch didWhat {
case "likePost":
subtitle = "liked your post"
case "commentPost":
subtitle = "commented on your post"
case "likeComment":
subtitle = "liked your comment"
case "message":
subtitle = "sent you a message"
case "friendsRequest":
subtitle = "sent you a friend request"
case "friendAccept":
subtitle = "accepted your friend request"
case "follow":
subtitle = "just followed you"
default:
break
}
getOneSignalPlayerID(receiverID, completion: { result in
oneSignal.postNotification(["headings" : ["en": "\(who)"],
"subtitle" : ["en": "\(subtitle)"],
"contents" : ["en": "\(contents)"],
"include_player_ids": [result]],
onSuccess: { (success) in
if success != nil {
print(success!)
}
}, onFailure: { (failure) in
if failure != nil {
print(failure!)
crashlyticsLog("getOneSignalPlayerID", failure!.localizedDescription)
}
})
})
}
我缺少什么?非常感谢您的帮助。