![](/img/trans.png)
[英]How to send push notification from Firebase to web app on iOS device?
[英]Why push notification directed to specific iOS device from Web API through Firebase FCM does not arrive?
我正在与一个远程Web API开发人员合作,目前我们正在将推送消息从服务器发送到iOS和Android设备。 我们通过OAuth API发送设备令牌。 (对于iOS,设备令牌是通过在AppDelegate启动时向APNS服务注册远程服务获得的)。 奇怪的是,Android可以获取推送通知,而iOS设备却不能。 但是,当我尝试使用Firebase控制台->增长->通知->新消息->并定位所有iOS设备时,所有注册到推送通知中的iOS设备都会收到推送通知。 您能帮我指出问题出在哪里吗? Web服务器正在使用nodeJs。
根据本教程我所做的事情:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
// For iOS 10 data message (sent via FCM
Messaging.messaging().delegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
FirebaseApp.configure()
return true
}
通过所有这些准备工作,如果我在真实的iOS设备上运行该应用程序,然后将其锁定,则我在Firebase iOS应用程序中广播到iOS设备的任何消息都将显示在锁定屏幕通知中。 但不是来自Web API的消息直接定向到应用程序中登录的帐户(定向到使用该帐户登录的所有android和iOS设备-在android设备上显示,但在iOS设备上未显示)。
我是FCM的新手。 我通常使用APNS。 我可能不太了解用于修复服务器端的术语,因为我不太了解nodeJ,因此,如果您对服务器端有一些建议,请详细说明,以便与Web API开发人员进行讨论。 谢谢你的帮助。
原来我需要发送到服务器的不是APNS令牌,而是Firebase令牌,可在以下位置找到:
https://firebase.google.com/docs/cloud-messaging/ios/client#monitor-token-generation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.