Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to import UserNotifications in iOS Swift

I'm trying to implement push notification by using Firebase. I have installed the 'Firebase/Core' and 'Firebase/Messaging' frameworks using cocapod. I'm able to import FirebaseInstanceID & FirebaseMessaging in the File. But for "import UserNotifications" it says "No Such Module". I'm using Swift 2.1.1 and Xcode 7.3.1 and my targeted iOS is 8.1+ ... Kindly Help, thanks in advance .

like image 291
Aaliya Avatar asked Jan 25 '26 10:01

Aaliya


1 Answers

Upgrading to XCode 8 is probably the best option.

But if you can't or don't want to upgrade for some reason you can use old way of APN Registration (without importing UserNotifications):

    let settings: UIUserNotificationSettings =
        UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    application.registerUserNotificationSettings(settings)
    application.registerForRemoteNotifications()

Firebase Messaging will work, but some new iOS10 features might not function.

like image 158
Vitalii Avatar answered Jan 28 '26 00:01

Vitalii