gpt4 book ai didi

ios - 如何解决: language content complaining with OneSignal in Swift

转载 作者:搜寻专家 更新时间:2023-10-30 22:12:36 26 4
gpt4 key购买 nike

我正在使用 OneSignal 来管理我的推送通知。对于某些通知,我收到:

Notifications must have English language content

但我用英语发送所有内容...

oneSignal.postNotification(["headings" : ["en": "\(who)"],
"subtitle" : ["en": "\(subtitle)"],
"contents" : ["en": "\(contents)"],
"include_player_ids": [result]],

who, subtitle, contents 都是String,result是receiver 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)
}
})
})
}

我错过了什么?非常感谢您的帮助。

最佳答案

我假设这 4 个字段之一是错误的。在这种情况下错误可能意味着它有一些非法字符或非英语编码中的字符。在发布通知之前打印每个字段。

引发此错误的另一种情况可能是因为其中一个字段为空或为零。在发布通知之前再次将它们打印到日志中。

关于ios - 如何解决: language content complaining with OneSignal in Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40791415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com