【发布时间】:2019-07-05 02:56:15
【问题描述】:
我没有收到来自 firebase 的任何通知,但是当我使用 Pusher 应用程序进行测试时,我收到了通知。
这些是我已经完成的步骤。如果我做错了什么,请帮助我。
1_添加notificationService如下。
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
bestAttemptContent.title = "hello"
bestAttemptContent.body = "this is test"
contentHandler(bestAttemptContent)
}
}
}
2 _ 在应用代理中将 notificationCenter 代理设置为自己
Messaging.messaging().delegate=self
UNUserNotificationCenter.current().delegate = self
3_ 用于发送通知的设备令牌(我将其存储到服务器)
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
let dataDict:[String: String] = ["token": fcmToken]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
}
我将此 FCMToken 发送到服务器端(java,spring boot)
4_ 我已在 Capabilities 中启用推送通知
5_ 我已在 firebase 控制台中项目设置的云消息传递中添加了 .p12 文件,但我对此有很大的疑问!????我应该使用我的服务器帐户登录到 firebase 吗?或者为我自己做一个帐户??因为我为自己创造了一个。
一些提示:
我们是一个像服务器端(JAVA)这样的团队。网页、安卓和ios
此推送通知在 android 上有效,但在 ios 上无效。
我认为我做错了事。
感谢您阅读本主题并帮助我。
【问题讨论】:
标签: java ios swift firebase firebase-cloud-messaging