Xcode控制台中显示Firebase/InAppMessaging错误
为什么会出现这种错误? 我也正确地阅读了文档、设置代码和项目,但是当我从firebase deshboard发送InAppMessaging并打开应用程序时,我收到了这个错误Xcode控制台中显示Firebase/InAppMessaging错误,firebase,firebase-in-app-messaging,Firebase,Firebase In App Messaging,为什么会出现这种错误? 我也正确地阅读了文档、设置代码和项目,但是当我从firebase deshboard发送InAppMessaging并打开应用程序时,我收到了这个错误 pod 'Firebase/Database' pod 'Firebase/InAppMessagingDisplay' pod 'Firebase/Messaging' 这背后有2-3个原因 Firebase未在didFinishLaunchingWithOptions配置/初始化 FCM令牌已过期或无效,并且
pod 'Firebase/Database'
pod 'Firebase/InAppMessagingDisplay'
pod 'Firebase/Messaging'
这背后有2-3个原因
- Firebase未在didFinishLaunchingWithOptions配置/初始化
- FCM令牌已过期或无效,并且未添加刷新令牌
- 使用无效/不同的GoogleService-Info.plist i、 e如果您在同一项目中使用2 GoogleService-Info.plist进行开发和生产。因此,请确保在安装应用程序时,正确的GoogleService-Info.plist正在启动
[Firebase/InAppMessaging][I-IAM130004] Failed restful api request to fetch in-app messages: seeing http status code as 400 with body as {
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
[Firebase/InAppMessaging][I-IAM700002] Error happened during message fetching Error Domain=NSURLErrorDomain Code=400 "(null)"
我也有同样的问题。你解决了吗?是的,我的问题通过添加pod步骤1-#pod“Firebase/InAppMessagingDisplay”步骤2-pod安装步骤3-通过代码消息配置Firebase解决了。消息().shouldEstablishDirectChannel=true步骤3-从iPhone中删除应用程序并重新安装-向firebase发送APNS令牌,但添加
shouldEstablishDirectChannel
更改应用程序接收firebase消息的行为
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: CGRect(x: 0, y: 0, width: kDeviceWidth, height: kDeviceHeight))
FirebaseApp.configure()
NotificationCenter.default.addObserver(self, selector: #selector(tokenRefreshNotification), name: NSNotification.Name.InstanceIDTokenRefresh, object: nil)
Messaging.messaging().delegate = self
Messaging.messaging().shouldEstablishDirectChannel = true
UNUserNotificationCenter.current().delegate = self
if #available(iOS 10.0, *) {
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
}
// [START refresh_token]
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
//You save or send fcm token to your sever
}
//+++++++++++++++++++++++
// FCM Token Get Refreshed
@objc func tokenRefreshNotification(_ notification: Notification) {
getFCMToken()
}
private func getFCMToken() {
InstanceID.instanceID().instanceID { (result, error) in
if error == nil {
if let result = result {
let fcmToken = result.token
//Save or send to your server
}
}
}
}