ios - 使用 Google Firebase 通知构建错误

标签 ios swift xcode firebase swift3

我最近开始使用 Firebase,特别是它的通知系统。但是当我运行代码时,出现此错误:

Error: URL scheme needed for Google Sign-In not included in your app's Info.plist. Please refer to the Google Sign-In SDK documentation for more information.'
*** First throw call stack:
(0x1877c2fe0 0x186224538 0x1877c2f28 0x10017c694 0x10017c114 0x18775d5f4 0x18775cd08 0x18775ca84 0x1877cb7a8 0x1876a095c 0x1881b2930 0x100089078 0x100087dac 0x100087aa4 0x100025f64 0x1000265b8 0x18d9654dc 0x18db71678 0x18db77120 0x18db8bc58 0x18db743b4 0x18936b884 0x18936b6f0 0x18936baa0 0x18777142c 0x187770d9c 0x18776e9a8 0x18769eda4 0x18d95e65c 0x18d959330 0x100027fd0 0x1866ad59c)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

这是我的AppDelegate.swift

//
//  AppDelegate.swift
// 
//
//  Created by Pol on 22/04/17.
//  Copyright © 2017 Pol. All rights reserved.
//

//import UserNotifications
import UIKit
import CoreData

import UserNotifications
import Firebase
import FirebaseInstanceID
import FirebaseMessaging

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        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
            FIRMessaging.messaging().remoteMessageDelegate = self
        } else {
            let settings: UIUserNotificationSettings =
            UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
        }

        application.registerForRemoteNotifications()

        FIRApp.configure()

        return true
    }


    // The callback to handle data message received via FCM for devices running iOS 10 or above.
    func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
        print(remoteMessage.appData)
    }

}


Thank you beforehand for your help!

最佳答案

来自The documentation :

Google Sign-in requires a custom URL Scheme to be added to your project. To add the custom scheme:

  1. Open your project configuration: double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section
  2. Click the + button, and add a URL scheme for your reversed client ID. To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration page. Leave the other fields blank.

关于ios - 使用 Google Firebase 通知构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43833367/

相关文章:

ios - 如何更改第二个 UIWindow 的状态栏颜色?

ios - AFNetworking 2.0 AFHTTPRequestOperationManager CachePolicy 不工作

ios - Multipeer Connectivity 如何获取广告对等点的名称?

ios - 如何在 iOS 上的给定日期执行后台任务?

ios - 延迟循环(倒计时功能)

iOS:事件指示器停止后如何执行一段代码?

xcode - 如何创建一个搜索路径类似于 <Google/Analytics.h> 的 cocoa-touch 框架

ios - 将 UITextView 的文本从一个 View 更改为另一个 View

Swift - 通用函数参数

ios决定是否在客户端代码的某些条件下静音我的远程通知,而不是设置内容可用