How Push Notifications Work on iOS and Android

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so this video is going to be an overview of how notifications work on ios and android and we'll start with permissions um android doesn't require you to ask for permission to display push notification you're just given permission by default but a user can revoke permissions um at any time either for your whole app for a specific channel or for a channel group now ios requires you to ask permission from the user before you can display a push notification the only recent change to that is after ios 12 you're allowed to send quiet notifications which are just notifications that are only visible within the device notification center and you don't have to request permission for that ios has three permission states the first is not determined and that's the status when somebody first installs your app and you haven't asked them for permission to send push notifications the other two options are granted or declined and after you ask the user if you can send them push notifications they can either grant it or they can decline it and if they decline it then you can't ask them again it's a one-time deal after they decline it if the user wants to get push notifications from you they have to manually go into the ios settings app and allow your app to send push notifications you can create local notifications or remote notifications local notifications are ones that are created on device and remote notifications are ones that come from a server so an example of a local notification is a timer so say you have an app you set a timer you know notify me in two minutes from now that is something that you can create on the device schedule two minutes from from the time it was created and then the app will get a push notification in two minutes the remote notification is is the one that's much more common you know it's one that gets sent to you from a server based off of you know basically anything any reason you decide to send a push notification your push notification can have a visual notification you know like what you're seeing on your phone if somebody likes a post and you get notified that they like it you see it but you can also send a push notification that's just data so you don't actually see a visible notification but the app does get notified with some incoming data and then you can do things in the background like sync a message you know sync a message or something like that and you can have a combination of both so you can send a visual notification that also includes some kind of data after you've sent a notification you can update that notification later instead of creating a new one and if you need to get rid of that notification altogether you can cancel it so that it'll just be removed from the notification center you can set up a listener to handle background notifications it works a little bit different on ios than on android so on android you have a headless js test that runs separate from the main app that you can do some processing on there on ios the device will silently start up in the background and then you can make some network requests or update local storage so how do you send a notification to a device well you can think of it there's two separate ways you either send a notification to a specific phone or you send a notification to a group of devices if you want to send a notification to a specific device the first thing you have to do is when that user launches the app you need to get that device token and save it to your server somewhere and then when you're ready to send the notification you send a notification with that token so it can be delivered to the specific device you want the thing is tokens are assigned to a device so you may run into issues if you have more than one person using the same device if one person logs in and then you save that device token to their you know account on your servers and then they log out and then a new person logs in you don't want that second person to get notifications for the first person best practice is when somebody logs out of a device you need to clear out the device token and you also need to send a request to your server to clear out that saved token so then when the next person logs in you register the new token on your server for this new user you can also send messages to multiple devices without needing to use a specific device token and with firebase you do that by subscribing to a topic so the person still needs to launch the app so you can subscribe them to the topic but then once they're subscribed you can just send a notification to everybody that's subscribed to that specific topic and then you can also allow users to unsubscribe for that topic if they don't want to get notifications so now you've sent a notification what do you do when somebody taps on that notification well the default behavior is just to have the app open when somebody taps on the notification and that's simple enough what's really interesting is doing things with deep links so take for example instagram say you get a push notification that says so and so commented on one of your posts well that notification can come with some extra data that deep links into that specific post so when the user taps on it it takes them to that post in the app so they can reply back to that comment you can also have quick actions on your notifications so so user can take an action without having to go into the app so say for example you have a chat app and you send a push notification that a new message has come in so somebody can see the message in the push notification and you could add a quick action on there so they can just mark that message as read without having to go all the way into the app another thing you could do is you have a quick action with a text input so then the person could reply to that message without ever having to go into the app so that's just a basic overview of how push notifications work for both ios and android if you have any questions just let me know
Info
Channel: Jimmy Cook
Views: 8,726
Rating: undefined out of 5
Keywords: react native, programming, coding, tutorial, app, app development, ios, android, cross-platform, guide, javascript, push notifications
Id: 4BFRAQuuEfc
Channel Id: undefined
Length: 7min 8sec (428 seconds)
Published: Mon Jul 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.