Nous évaluons actuellement Firebase en tant que service de notification de poussée futur. Existe-t-il un moyen d'envoyer des notifications actionnables aux appareils iOS? Pour le moment, nous utilisons l'analyse pour envoyer des pousses, nous définissons le paramètre "Catégorie" dans la charge utile et les actions supplémentaires sur les notifications fonctionnent. Nous avons essayé de définir ce paramètre dans la console Firebase ou via l'API de repos de Firebase, mais les actions de notification ne fonctionnent pas, il semble que la charge utile est en quelque sorte différente puis IOS s'attend. P>
3 Réponses :
Catégories actuellement non prises en charge dans Console FCM forte> mais toujours si vous souhaitez tester, vous pouvez utiliser Curl Post Call and Test. Vous pouvez ajouter une catégorie à votre charge utile à partir de votre serveur et utilisez API FCM pour appuyer une notification sur iOS. {
aps = {
alert = {
body = "Would you like to accept shift today 11:30 to 13:30 ";
title = "Shift Alert";
};
category = "INVITE_CATEGORY";
};
"gcm.message_id" = "0:12233487r927r923r7329";
}
Il existe deux mauvais espaces dans la demande dans "Type de contenu", voici la version correcte: curl -header "Autorisation: clé =
merci Malik pour la réponse. La FCM semble traduire la propriété "click_action" android sur la propriété "catégorie" spécifique iOS.
Nous envoyons des notifications push Firebase via leur API de repos, qui peut être facilement utilisée pour tester avec facteur. P>
Voici la version de repos: p>
POST FORT> HTTPS: // fcm.googleapis.com/fcm/send p> en-têtes: p> corps: p>
Je créé une méthode simple JS pour mon PC local pour envoyer une notification push avec la catégorie. J'utilise Node
//Call when application loaded func registerNotification(_ application: UIApplication) { //Firebase callback Messaging.messaging().delegate = self Messaging.messaging().subscribe(toTopic: YOUR_TOPIC_NAME) { error in print("Subscribed to notification topic") } //IOS Notification (ios 10 and above) UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().requestAuthorization( options: [.alert, .badge, .sound], completionHandler: {_, _ in }) application.registerForRemoteNotifications() //Add custom actions let acceptAction = UNNotificationAction(identifier: "view_now", title: "Xem ngay", options: .foreground) let skipAction = UNNotificationAction(identifier: "skip", title: "Bá» qua", options: .foreground) // Define the notification type let viewCategory = UNNotificationCategory(identifier: "VIEW_NOTIFICATION", //category name actions: [acceptAction, skipAction], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "", options: .customDismissAction) // Register the notification type. let notificationCenter = UNUserNotificationCenter.current() notificationCenter.setNotificationCategories([viewCategory]) } func viewNotification(_ userInfo: [AnyHashable : Any]) { //handle extra data let id = (userInfo["id"] as? String) ?? "" let title = (userInfo["title"] as? String) ?? "" let url = userInfo["url"] as? String NotificationService.shared.viewNotification(id, title: title, url: url) } //MARK: UNUserNotificationCenterDelegate func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler(.alert) } func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { // if user tap or response to not "skip" action we can handle here let userInfo = response.notification.request.content.userInfo if response.actionIdentifier != "skip" { viewNotification(userInfo) } // Always call the completion handler when done. completionHandler() }