Setting up Push Notifications with FCM
Instagram Firebase
Push Notifications are an essential part of increasing engagement of users for your applications. With the help of Firebase Cloud Messaging, it is very easy to register your devices and send segmented notifications or individual notifications to your users. In today's lesson, we will be registering an App ID in Apple's Developer console to allow our application to receive push notifications. This process requires a developer's account with Apple that costs $99/yr. There isn't any way around this and it's money developers have to dish out every year.

Comments (22)
andrew9bernard
5 years ago
Great stuff Brian. Love that you are releasing videos on this. Will you give us some pointers on how we can incorporate push when someone you are following makes a new post? Thanks
Brian Voong
5 years ago
andrew9bernard
5 years ago
I am sure with the way that you teach us through the videos figuring out how to do other notifications will be easy. Thank you for that. Any video to paginate the home feed would be greatly appreciated. Thank you for all your hard work.
diehard98
5 years ago
Thank you Brian. It is again great video. I was able to setup notification without FCM token. Somehow it works just fine for my code. :) But somehow didReceiveRegistrationToken was not presented on auto-completion. So, I manually typed that in then it is not complaining about error but it is not called when app starts up. I looked google document and I tried to get fcmToken directly from Messaging.messagin().fcmToken in application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) function and it was printing token successfully. I am not sure if didReceiveRegistrationToken is not implemented at MessagingDelegate anymore. :)
Brian Voong
5 years ago
josiahsavino
5 years ago
how can we implement func messaging? the "didRecieveRegistationToken" is no longer available?
wasim
5 years ago
Correction: 99$/year not month
Brian Voong
5 years ago
abdul
5 years ago
The only thing now I need, is to buy "Time" LOL
Brian Voong
5 years ago
josiahsavino
5 years ago
I dont ever recall being so happy to give someone money for education. I have watched infinite hours from Brian and he is by far the best teacher I have come across in Swift. He teaches how to be self sufficient as a programmer and is incredibly knowledgeable. I spent an entire day looking online trying to learn how to setup up notifications for my app and he makes it a breeze in less than 30 minutes. Thanks for teaching me the tools to make my App Ideas come to life. Much Love Josiah Savino
Brian Voong
5 years ago
stonypig1
5 years ago
Mr.Brian can you please add one more short lesson which teach us using a toggle how to turn this notification on and off inside the app? thanks p.s. if anyone already done it, please leave me a reply or link show me how to do it. thanks
蔣一昕
5 years ago
Hi Brian, I just wanna say : How could you always make tutorials we just need ? :D . I cant even count how much I've learned from your videos Keep up the great work! Jamie, support from Taiwan.
Obrac
5 years ago
Hey Brian, I wanted to say thanks, man. I will speak for myself, though I think many here believe the same, you've been by far a great teacher of swift. Really glad I took the plunge with the CoreData and Instagram course. Any ideas when we'll touch messaging in-app messages/chat?
Yoel Lev
5 years ago
Hi there, Firebase has changed some stuff, so just letting you know, I needed to explicitly map my APN token to the FCM registration token in the didRegisterForRemoteNotificationsWithDeviceToken for my PushNotifications to work : Messaging.messaging().apnsToken = deviceToken Hope it will help (:
caquillo07
5 years ago
THANK YOU!! this was driving me insane. I wish I could upvote this so that its always at the top of the comments
Yoel Lev
5 years ago
my plasure caquillo07, I think its a good idea for Brian to implement it here...
leandroare
5 years ago
Hi Brian, firebase has changed ReceiveReceiveRegistrationToken with didRefreshRegistrationToken. Now do not print the token. Please help. Thank you.
cesarvelascou
5 years ago
Hi Brian, I´ve tried making my UserProfileHeader look like yours (get number of posts, followers and following right), but I´ve only been able to get the posts correctly. Can´t really manage to get the "following" (I´ve been able to achieve this correctly just for the current user) or the "followers" section. I´ve also noticed you´ve implemented this features in your app, but haven´t found the implementation on your code. Am I missing it or is it not on your files? If not, can you please (please, please) share it here. I really can´t figure it out. It would be greatly appreciated. :D
stonypig1
5 years ago
great stuff, follow your steps and got my notification work. but one question, it says in apple developer page says it works on development , but if we are going to production which I guess it means if we want to publish to apple store, what do we need to do ? thanks
chasekling
5 years ago
Hi Brian or anyone who may know, 1. Are we allowed to deploy this to the apple store? I'd like to do so in order to show potential employers that I have gone through this process. 2. Would the apple review team even accept this app as it is essentially a copy of Instagram (with less features of course). I'd also like to thank you Brian! This has been such an engaging course and the lessons I've learned will be immensely helpful moving forward in my career. I can't tell you how much I appreciate you putting this course together. We need more teachers like you in the community :)
malrhex
4 years ago
Men I am in the same situation, to show to the employers but how does it was for you? did you get the job? did you get any red flag?
sherdiddy
4 years ago
Hey man, were you successful to upload this on apple store? cuz i also wanna do like this
johnbran69
4 years ago
Hi Brian, How would you handle situations where the user is logged on to several devices? Would you save the FCMs to the user db as an array and then have firebase cycle through them to send notices to each?
Stephan Dowless
4 years ago
email me at dowless.stephan@gmail.com for how to paginate home feed, implement hashtags/mentions and more
Alex Alx
4 years ago
You should have a like button, which users can hit multiple times :-) I have already implemented this in a couple of apps, but I always come here so I can follow the steps correctly. Great job!
malrhex
4 years ago
Does modifying the bundle identifier affects firebase?
malrhex
4 years ago
my question were answerd at 16:50 min of the video. thanks.
startingpoint
4 years ago
did apple turn off allowing notifications when app in foreground, in iOS 13?
Brian Voong
4 years ago
Cinquain
4 years ago
Video was lit
mao
3 years ago
Hello Brain, for some reason I receive no notification when the app is in foreground after updating swift to 5.1. The notification is triggered when I open the app. I see there is a change on Firebase regarding Firebase cloud messaging delegate. I am not sure if that is the reason.
mao
3 years ago
FIXED: Hello Brain, for some reason I receive no notification when the app is in background after updating swift to 5.1. The notification is triggered as soon as I open the app. I see there is a change on Firebase regarding Firebase cloud messaging delegate. I am not sure if that is the reason.
mao
3 years ago
Firebase currently has: 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 }) } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } application.registerForRemoteNotifications() Yours is: print("Attempting to register APNS...") Messaging.messaging().delegate = self UNUserNotificationCenter.current().delegate = self let options: UNAuthorizationOptions = [.alert, .badge, .sound] // ask user for authorization via a popup alert UNUserNotificationCenter.current().requestAuthorization(options: options) { (granted, err) in if let err = err { print("Failed to request auth:",err) return } if granted{ print("Auth granted") } else { print("Auth denied") } } application.registerForRemoteNotifications() May I ask what the differences are between these two?
benpalmer661
3 years ago
EVERYONE! make sure you set FirebaseAppDelegateProxyEnabled in the plist to YES , this had me stuck for a day.
古明智
2 years ago
I can't get the notification. i don't know write code in appdelegate or scenedelegate. Can anyone help me
HELP & SUPPORT