Ios FCM推送通知如何获取数据和显示自定义横幅
我正在开发小应用程序,我想向我的应用程序发送推送通知。一切都安排好了。而且工作很好。但是现在我想发送自定义通知,并显示接收fcm推送通知时显示的自定义横幅 我在安卓系统中很容易做到这一点,但在iOS中我有一些困惑。这里有一些我没有得到的东西,我不知道该做什么 我想要的:以下是我的应用程序要求:Ios FCM推送通知如何获取数据和显示自定义横幅,ios,firebase,firebase-cloud-messaging,Ios,Firebase,Firebase Cloud Messaging,我正在开发小应用程序,我想向我的应用程序发送推送通知。一切都安排好了。而且工作很好。但是现在我想发送自定义通知,并显示接收fcm推送通知时显示的自定义横幅 我在安卓系统中很容易做到这一点,但在iOS中我有一些困惑。这里有一些我没有得到的东西,我不知道该做什么 我想要的:以下是我的应用程序要求: 我想展示定制横幅 我想解析服务器发送的数据并保存在UserDefaults中 我在做什么:我正在从服务器发送推送并接收横幅,但它显示了正文中的所有数据,下面是我的应用程序代理 我的服务器发送的结构如下
- 我想展示定制横幅
- 我想解析服务器发送的数据并保存在UserDefaults中
没人知道吗?你能告诉我你是如何为android制作横幅的吗
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print("Did Receive")
completionHandler()
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
print("Will Present")
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print("Did Receive remote notification")
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("Did Receive device token")
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
}
/// Register for push notifications
func registerForPushNotification(){
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil{
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
} else {
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
UIApplication.shared.registerUserNotificationSettings(settings)
UIApplication.shared.registerForRemoteNotifications()
}
}
{
"to": "fBEk6eQ5I60:APA91bHR0IOZTBFJnFFxM9....GfeOGcoq-mBEUxj3ubab0x",
"priority": "high",
"force_start": 1,
"notification": {
"body": {
"UserId": 20054,
"IsLogout": false,
"DeviceId": "D58sada80-...-F8Asdasa147F",
"Title": "Score App",
"Message": "Today match suspended (Tue Oct-08-19 13:01)"
},
"title": "Score App",
"content_available": true,
"sound": "default",
"priority": "high"
}
}