Używam OneSignal do zarządzania moimi powiadomieniami push. Dla niektórych zgłoszeń, Otrzymuję:Jak rozwiązać: treść narzekająca na OneSignal w Swift
Powiadomienia muszą mieć zawartość
języka angielskiego Ale jestem tylko wysyłania wszystko w języku angielskim ...
oneSignal.postNotification(["headings" : ["en": "\(who)"],
"subtitle" : ["en": "\(subtitle)"],
"contents" : ["en": "\(contents)"],
"include_player_ids": [result]],
Kto, podtytuł, treść to Ciągi, wynik to identyfikator odbiorcy. Większość powiadomień jest wysyłanych, dla niektórych otrzymuję komunikat o błędzie.
konsoli:
> ERROR: Create notification failed
Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
errors = (
" Notifications must have English language content"
);
}}
Moja pełna funkcja:
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)
}
})
})
}
Czego mi brakuje? Pomoc jest bardzo cenna.
wygląda masz rację. Miałem funkcję z opcjonalnymi wartościami, wysyłając puste ciągi, na przykład jako treść podtytułu ... bardziej konkretny komunikat o błędzie byłby pomocny ... dziękuję za pomoc –
Twoje powitanie. Proszę oznaczyć jako "odpowiedź". – Vincent
. i ja również nagrodzę cię nagrodą. pozostało tylko 6 dni do zdobycia nagrody i może ktoś ma przydatne wskazówki lub coś w tym stylu. nie martw się. nie zapomnę o tobie. –