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!
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!
UPDATED: SWIFT 3.0:
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:
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.
Once you're inside the folder in Terminal, write:
$ pod init
and new file will be created for you inside the project called Podfile
Open Podfile file in your text editor and add pod 'Firebase' before the end keyword.
Save the file and go back to Terminal and make sure you are still inside the project path.
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.
https://www.mobiloud.com/help/knowledge-base/how-to-export-push-notification-certificate-p12/
Open your project and navigate to AppDelegate and do the following;
// Import framework
import Firebase
on the top of your App.
Now inside application:didFinishLaunchingWithOptions: method add
// Use Firebase library to configure APIs
FIRApp.configure()
Inside registerForRemoteNotifications method add the following:
let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
UPDATED: SWIFT 3.0:
UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.badge,.sound]) { (granted:Bool, error:Error?) in
if granted {
}else{
}
}
UNUserNotificationCenter.current().delegate = self
and for the delegate:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
}
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"]!)")
}
Follow the link below to test sending a push
https://firebase.google.com/docs/notifications/ios/console-device
There is a thing provided by any SDK, which is called Documentation. And here is the link to Firebase documentations. Follow this step by step its well explained.
Also you can find the example project for FCM(cloud messaging) from this GitHub's repository under messaging.
During this journey if you got stuck anywhere, then post your real question(problem) here, someone can guide you through.