Search code examples
swiftfirebasefirebase-realtime-databaseios10firebase-notifications

Firebase Notifications and Firebase Database features do not work at the same time in my app


I'm a new user to stack overflow but have been using the website anonymously for several months now. I've integrated Firebase into my iOS 10 (Swift 3) app, everything works fine but if I use Firebase Database, then I will not be able to use Firebase Notifications (meaning I won't receive my remote notifications that I have sent using Firebase).

Here is my code below:

override init() {

FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true

}


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let types : UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
    let settings = UIUserNotificationSettings(types: types, categories: nil)
    application.registerForRemoteNotifications()
    application.registerUserNotificationSettings(settings)

    return true
}

Solution

  • Yes you can use both. It's documented pretty well on how to setup FIRDatabase: https://firebase.google.com/docs/database/ios/start

    I've just built an app with both Messages and Notifications. Use CocaPods to manage and install all your dependancies.