当我使用使谈话成为可能的代码进行操作时,我可以和这个班见面吗?帮助我参加一个好的班级,发送标语或知道该班级的错误。
this.db.list
激活码
import UIKit
class FirebaseM {
func sendPushNotification (notData: [String: Any]){
let url = URL(string: "https://fcm.googleapis.com/fcm/send")!
var request = URLRequest(url: url)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
let serverKey = "key=AAAA_XXXXXXXXXXX"
request.setValue (serverKey, forHTTPHeaderField: "authorization")
request.httpMethod = "POST"
request.httpBody = try? JSONSerialization.data(withJSONObject: notData, options: [ ])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
print ( "1:",error ?? "")
return
}
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {
print ("statusCode should be 200, but is \(httpStatus.statusCode)")
print (response ?? "")
}
let responseString = String(data: data, encoding: .utf8)
print (responseString ?? "")
}
task.resume()
}
}