为什么通过 Firebase FCM 从 Web API 定向到特定 iOS 设备的推送通知没有到达?
Why push notification directed to specific iOS device from Web API through Firebase FCM does not arrive?
我正在与远程网络 API 开发人员合作,目前我们正在努力将推送消息从服务器发送到 iOS 和 Android 设备。我们通过 OAuth API 发送我们的设备令牌。 (对于 iOS,设备令牌是通过在 AppDelegate 启动时向 APNS 服务注册远程服务获得的)。奇怪的是,Android 可以收到推送通知,但 iOS 设备不能。但是当我尝试使用 Firebase 控制台 -> 增长 -> 通知 -> 新消息 -> 并定位所有 iOS 设备时,注册到推送通知的所有 iOS 设备都会收到推送通知。你能帮我指出问题出在哪里吗? Web 服务器正在使用 nodeJs。
我做过的事情,我是按照这个做的tutorial:
- 在 Firebase 项目中创建新应用。
- 为应用程序提供相同的产品包 ID。
- 将 google plist 导入 Xcode 项目。
- 向应用程序提供开发和生产证书.p12。
- 通过 Cocoapods 安装 Firebase/Core 和 Firebase/Messaging。
- 使用此代码注册远程通知(已在目标部署 iOS 版本 9.0 和 10.0 中都尝试过,两者都产生相同的结果):
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 应用程序将显示在锁屏通知中。但不是来自网络 API 的消息指向应用程序中登录的帐户(它指向所有使用该帐户登录的 android 和 iOS 设备——它显示在android 设备,但不在 iOS 设备上)。
我是 FCM 新手。我一般用APNS。我可能不太了解修复服务器端的术语,因为我不太了解nodeJs,所以如果您对服务器端有什么建议,请详细说明,以便我可以在网络上讨论API 开发者。感谢您的帮助。
原来我需要发送到服务器的不是 APNS 令牌,而是 Firebase 令牌,可以在这里找到:
https://firebase.google.com/docs/cloud-messaging/ios/client#monitor-token-generation
我正在与远程网络 API 开发人员合作,目前我们正在努力将推送消息从服务器发送到 iOS 和 Android 设备。我们通过 OAuth API 发送我们的设备令牌。 (对于 iOS,设备令牌是通过在 AppDelegate 启动时向 APNS 服务注册远程服务获得的)。奇怪的是,Android 可以收到推送通知,但 iOS 设备不能。但是当我尝试使用 Firebase 控制台 -> 增长 -> 通知 -> 新消息 -> 并定位所有 iOS 设备时,注册到推送通知的所有 iOS 设备都会收到推送通知。你能帮我指出问题出在哪里吗? Web 服务器正在使用 nodeJs。
我做过的事情,我是按照这个做的tutorial:
- 在 Firebase 项目中创建新应用。
- 为应用程序提供相同的产品包 ID。
- 将 google plist 导入 Xcode 项目。
- 向应用程序提供开发和生产证书.p12。
- 通过 Cocoapods 安装 Firebase/Core 和 Firebase/Messaging。
- 使用此代码注册远程通知(已在目标部署 iOS 版本 9.0 和 10.0 中都尝试过,两者都产生相同的结果):
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 应用程序将显示在锁屏通知中。但不是来自网络 API 的消息指向应用程序中登录的帐户(它指向所有使用该帐户登录的 android 和 iOS 设备——它显示在android 设备,但不在 iOS 设备上)。
我是 FCM 新手。我一般用APNS。我可能不太了解修复服务器端的术语,因为我不太了解nodeJs,所以如果您对服务器端有什么建议,请详细说明,以便我可以在网络上讨论API 开发者。感谢您的帮助。
原来我需要发送到服务器的不是 APNS 令牌,而是 Firebase 令牌,可以在这里找到:
https://firebase.google.com/docs/cloud-messaging/ios/client#monitor-token-generation