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

Поделиться
HTML-код
  • Опубликовано: 2 ноя 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

  • @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 //

  • @richardhasson265
    @richardhasson265 3 года назад +5

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

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi 2 года назад

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

  • @MrEmanuelFeijo
    @MrEmanuelFeijo Год назад +1

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

  • @pgong415
    @pgong415 Год назад

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

  • @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.

  • @amyc3713
    @amyc3713 Год назад

    This video is so helpful! I love Swiftful Thinking!

  • @ktmman1503
    @ktmman1503 Год назад

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

  • @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!

  • @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?

  • @eswar8406
    @eswar8406 2 года назад

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

  • @omerfarukozturk9720
    @omerfarukozturk9720 9 месяцев назад

    Your content is great. 💯

  • @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)
      }

  • @manoeltsf
    @manoeltsf Год назад

    Perfect explanation! Thaks a million

  • @hanniteMeister
    @hanniteMeister 6 месяцев назад

    Excellent session!!!!

  • @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?

  • @dugrut1325
    @dugrut1325 2 года назад +1

    amazing, love it!

  • @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.

  • @Rafaglg
    @Rafaglg 4 месяца назад

    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))")
    }
    }
    }
    }

  • @vladyslavsushko1967
    @vladyslavsushko1967 9 месяцев назад +2

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

  • @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.

  • @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 Год назад

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

  • @natealter7932
    @natealter7932 2 года назад

    Great video, youre a life saver mate

  • @andrejkling3886
    @andrejkling3886 3 года назад +1

    Good lesson.... thank you

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi 2 года назад

    Very helpful.. Thanks nick...

  • @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 9 месяцев назад

    Thank you so much!

  • @TBCS3000
    @TBCS3000 Год назад

    Could you please make a video about remote push notification

  • @RahafSaed-wv3ct
    @RahafSaed-wv3ct Год назад

    Is it okay use it deppend it weather ?

  • @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!

  • @HenningMoeller
    @HenningMoeller 2 года назад

    top video! love it

  • @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.

  • @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!

  • @EpicChicken8
    @EpicChicken8 Год назад +1

    18:45

  • @djiexn
    @djiexn 2 года назад

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