cannot replace \n from AnyHashable ios swift

141 Views Asked by At

so I have my push notif payload with \n and after I received, it showing "hey \ntsshis" tried to use replacingOccurences like this:

title = apnPayloadData!["alert"] as! String \\received it as hey \\ntsshis
title = title.replacingOccurrences(of: "\\n", with: "\n")  

Push notification received: Optional([AnyHashable("aps"): {
    alert = "hey \\ntsshis";
    badge = 1;
    sound = default;
}])

Optional([AnyHashable("sound"): default, AnyHashable("badge"): 1, AnyHashable("alert"): hey \ntsshis])

UPDATE

It works on title.replacingOccurrences(of: "\\n", with: "\n", options: .regularExpression) the output is hey *nextline tsshis

but when I set the value to [String: Any] the output remain the same

0

There are 0 best solutions below