How to schedule local Push Notifications in SwiftUI | Continued Learning #11

Поділитися
Вставка
  • Опубліковано 18 лис 2024

КОМЕНТАРІ • 52

  • @RaulRodriguez-bg2lq
    @RaulRodriguez-bg2lq Рік тому +1

    Certainly the best video on SwiftUI notifs I’ve seen so far, definitely going to help out on this project I’m starting

  • @richardhasson265
    @richardhasson265 3 роки тому +5

    Thanks for this and the explanation about incrementing the badge number. Very helpful ... as are all of your videos.

  • @CtheK
    @CtheK 2 роки тому +3

    Hi everyone,
    Very special thanks to Nick. I am following his videos for two weeks and gained experience like studying for 2 months!
    I am trying to update the "repeatNumber" value that I created in a struct.
    struct ItemModel: Identifiable, Codable {
    let id: String
    let title: String
    let detail: String
    let isCompleted: Bool
    let repeatNumber: Int //

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi 2 роки тому

    Nick lemme tell you something. Your SwiftfulThinking UA-cam channel should be the most recommended channel for the Swift UI on the whole UA-cam.❤️❤️❤️

  • @pgong415
    @pgong415 Рік тому

    Great video about local notification, indeed worth of time to watch it.

  • @MrEmanuelFeijo
    @MrEmanuelFeijo Рік тому +1

    Thanks for the hard work put on these videos. I hope that you keep it up 😉

  • @ktmman1503
    @ktmman1503 Рік тому

    Brilliant.. so helpful ! thank you.. keep them coming..

  • @amyc3713
    @amyc3713 Рік тому

    This video is so helpful! I love Swiftful Thinking!

  • @hanniteMeister
    @hanniteMeister 7 місяців тому

    Excellent session!!!!

  • @eswar8406
    @eswar8406 2 роки тому

    Thanks for this and the explanation ,your videos are Very helpful . My doubt was can we localized notification in app side

  • @manoeltsf
    @manoeltsf Рік тому

    Perfect explanation! Thaks a million

  • @omerfarukozturk9720
    @omerfarukozturk9720 9 місяців тому

    Your content is great. 💯

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi 2 роки тому

    Very helpful.. Thanks nick...

  • @andrejkling3886
    @andrejkling3886 3 роки тому +1

    Good lesson.... thank you

  • @dugrut1325
    @dugrut1325 2 роки тому +1

    amazing, love it!

  • @natealter7932
    @natealter7932 2 роки тому

    Great video, youre a life saver mate

  • @vladyslavsushko1967
    @vladyslavsushko1967 9 місяців тому +3

    IOS 17 deprecated : UIApplication.shared.applicationIconBadgeNumber
    UNUserNotificationCenter.current().setBadgeCount(0)

  • @pawelpow
    @pawelpow 3 роки тому +3

    Hello! Thanks for the tutorial, however I’ve got a question. How would I execute code at a specific time every day. For example, I want to reset an isCompleted variable daily, how would I go around and implementing this. Thank you for your time.

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +4

      You're probably better off resetting the variable when a user opens the app. Check the current time against the specific time and then reset!

  • @horosx9623
    @horosx9623 3 роки тому

    Hi, Thanks for this tutorial, it works Wally great. I was wondering if you could help ...How do I list all the notifications received in a View with swiftUI? Thanks heaps.

  • @zaidattar3535
    @zaidattar3535 2 роки тому +1

    Hello, thank you for the tutorial it was really helpful.But I was just trying to figure out how to schedule a notification at three different times a day. Or if I could schedule it for 9 am and make it repeat every 5 hours?

  • @TBCS3000
    @TBCS3000 Рік тому

    Could you please make a video about remote push notification

  • @Nunny25
    @Nunny25 3 роки тому +2

    Hello Nick, thanks for super tutorial. If I can ask You, would You be so kind and explain, how to increase number on app icon for example when You will receive more than 1 notification?

    • @Decatilinae
      @Decatilinae 3 роки тому +2

      I follow question too...

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +3

      Hi Charlie / Romesh.. great question! I should have touched on this in the video. It's actually a bit tricky. The problem is that we need to declare the badge number at the time that we schedule all of these local notifications. So the simple answer is that you could manually change the badge from 1 to 2 to 3 for each of the notifications. Alternatively, if your schedule a single notification and you want it to have a badge of 1 higher than the current badge, you could use NSNumber(value: UIApplication.shared.applicationIconBadgeNumber + 1). Again this is only +1 from the current value.

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +3

      So the more complex answer is that you could give the notifications custom IDs (which we did not do in the video) and if a user opens a notification, then track down that ID and reschedule all of the future notifications with updated badges.... I might do a video on this in the future, but in most cases, these local notifications are generic (not specific to the user) and are usually all sent with no badge or a badge of 1.

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +2

      Notifications that usually increment the badge are the real push notifications, like a new comment or like on a post. When scheduling these there's a whole different process that we use (usually an external service too) that will take care of the incrementing for us. That of course is not covered in this video and is pretty advanced. I'll be doing that in upcoming courses!

    • @Nunny25
      @Nunny25 3 роки тому

      @@SwiftfulThinking Hi Nick, thank You for very complex answer. To be honest, I do not know, how increase number of badges on icon when notification come on device. The app is in background at this moment. Maybe you can extend Your ToDo project with notifications in the future. I am new in SwiftUI and I have to see exact example to understand.

  • @paralysekid
    @paralysekid 2 роки тому +1

    Hi, thanks for the video. Now how do you execute some code when a user clicks on a notification?
    All the tutorials I can find are old and use AppDelegate functions that I don't know where to put in the SwiftUI structure. Would be happy if you could give even some advice.

  • @satyadodda2386
    @satyadodda2386 Рік тому

    Hey Nick!! How to perfrom an action along with notification like when ever the notification triggers i need to perform some action at the same time.Can you please help me how to do it?

  • @NOYT-India
    @NOYT-India 3 роки тому +1

    Hi Nick,
    Good evening, hope you are doing well, and keeping safe from covid,
    can you please make a video on server/remote push notification in swiftUI framework,
    Regards
    Ankit

  • @ordozgoite
    @ordozgoite 10 місяців тому

    Thank you so much!

  • @Wiintb
    @Wiintb 2 роки тому

    You should try teaching rocket engineering. Space X will be able to get a ton of engineers and we can go to Mars much earlier!

  • @demoel
    @demoel 3 роки тому +1

    Hello, thank you very much for sharing your knowledge, I have a question, in no part of the code I see that authorization is requested for geolocation, please help with that in how to include that authorization with the code you taught

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +2

      Hi Daniel, I have not covered MapKit and managing user's location yet. I will be covering it in an upcoming series. Sorry for the wait!

    • @Jump_Jay
      @Jump_Jay 2 роки тому

      @@SwiftfulThinking I was trying to do this with my phone today..... 😂😂😂 Looking forward to this! 😎✌

  • @dugrut1325
    @dugrut1325 2 роки тому +1

    I'm back, thought I put this in a real app

    • @SwiftfulThinking
      @SwiftfulThinking  2 роки тому

      Push Notifications are one of the best ways to increase retention / DAU!

  • @RahafSaed-wv3ct
    @RahafSaed-wv3ct Рік тому

    Is it okay use it deppend it weather ?

  • @HenningMoeller
    @HenningMoeller 2 роки тому

    top video! love it

  • @Rafaglg
    @Rafaglg 5 місяців тому

    within the completion handler we must used [weak self] if we are using a reference to the class notificationManager? for example
    class NotificationManager {
    static let shared = NotificationManager()
    var isNotification: Bool = false
    func requestAuthorization() {
    let options = UNAuthorizationOptions([.alert, .badge, .sound])
    UNUserNotificationCenter.current().requestAuthorization(options: options) { [weak self] success, error in
    if success {
    self?.isNotification = success // reference
    } else {
    print("error: \(String(describing: error?.localizedDescription))")
    }
    }
    }
    }

  • @demetrivondeufenbach7847
    @demetrivondeufenbach7847 3 роки тому

    Thanks for the video! Super helpful, just a question or two -- how do you view the simulator device's home page on canvas (what to click on the keyboard for it to show up when running?) Also, is there some way to let the user select the date/time of notifications instead of hard-coding it in the way we did in this video?

    • @SwiftfulThinking
      @SwiftfulThinking  3 роки тому +1

      Hey Demetri, you can use CMD + K to open the Keyboard on a simulator. And yea, you can build a UI for users to input their date/time and then run these same functions. Obviously you will need to make the date/time parameters.

  • @yevhen1748
    @yevhen1748 2 роки тому +3

    Hi, Nick! Your videos are awesome! But i got some problem with badge remove.
    onAppear block loads only once (at first launch time). If you get notification, get 1 new badge and open your application - onAppear will not work, because it did at 1st launch time.

    • @vladimirmoor
      @vladimirmoor 2 роки тому +3

      You can use an environment value called "scenePhase" and .onChange() closure.

    • @enesozmus
      @enesozmus 5 місяців тому

      It worked for me
      @Environment(\.scenePhase) var scenePhase
      .onChange(of: scenePhase) {
      UNUserNotificationCenter.current().setBadgeCount(0)
      }

  • @djiexn
    @djiexn 2 роки тому

    Hey its seems like its work How can I offer you a coffee?

  • @EpicChicken8
    @EpicChicken8 Рік тому +1

    18:45