Nuria Peralta Nuria Peralta - 4 months ago 18
iOS Question

ios Firebase Push Notification project

I'm very new at Firebase and i'm looking for an iOS project with push notifications implemented, to look how Firebase push notifications work and learn of it.
Can someone tell me where i can find it?

Thank you!

Jad Jad
Answer

How to integrate your iOS project with Firebase.

In Order to integrate your project with Firebase for push notifications you need to do the following:

  1. Integrate your project with Firebase by using CocoaPods. Open Terminal and write cd and then drag the folder that contains your project to the Terminal so you avoid writing the whole path.

  2. Once you're inside the folder in Terminal, write:

    $ pod init

and new file will be created for you inside the project called Podfile

  1. Open Podfile file in your text editor and add pod 'Firebase' before the end keyword.

  2. Save the file and go back to Terminal and make sure you are still inside the project path.

  3. Then write pod install in Terminal and this should start downloading Firebase and integrating it with your project.

6.Once done downloading you should see a new file in your project folder with .xcworkspace extension. This is the file you should open from now on.

  1. go to the link below and generate your certificate in order for you to upload it to your Firebase project in the console.

https://www.mobiloud.com/help/knowledge-base/how-to-export-push-notification-certificate-p12/

  1. Open your project and navigate to AppDelegate and do the following;

    // Import framework

      import Firebase
    

on the top of your App.

  1. Now inside application:didFinishLaunchingWithOptions: method add

    // Use Firebase library to configure APIs

    FIRApp.configure()
    
  2. Inside registerForRemoteNotifications method add the following:

     let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    
        application.registerUserNotificationSettings(settings)
    
        application.registerForRemoteNotifications()
    
  3. You should add the following method to your AppDelegate in order for you to receive messages while the app is running;

    func application(application:UIApplication,didReceiveRemoteNotification userInfo: [NSObject : AnyObject],fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {

    print("Message ID: (userInfo["gcm.message_id"]!)")

    }

  4. Follow the link below to test sending a push

https://firebase.google.com/docs/notifications/ios/console-device

Comments