Search code examples
iosswiftxcodefirebaseswift3

Error build with Google Firebase notification


I recently began to use Firebase, especially for its system of notifications. But when i run the code, I've got this error :

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)

Here is my 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!

Solution

  • You should remove import FirebaseInstanceID In the Appdelagate

    BEFORE:

        import UIKit
        import CoreData
    
        import UserNotifications
        import Firebase
        import FirebaseInstanceID
        import FirebaseMessaging
    

    AFTER:

        import UIKit
        import CoreData
    
        import UserNotifications
        import Firebase
        //import FirebaseInstanceID
        import FirebaseMessaging