HomeiOS Developmentios - Learn how to name an API at precisely 00 and...

ios – Learn how to name an API at precisely 00 and half-hour each hour in Swift?


I’m making an attempt to implement a repeating API name in my iOS app (Swift), and I would like the decision to occur at precisely 00 and half-hour of each hour (e.g., 1:00, 1:30, 2:00, and so on.).

  • On launch (when app is in foreground), I need to make the primary API name to verify if a slot is accessible.
  • Then, I need to schedule the API to run at each hour and half-hour mark.
  • This must be correct to the clock (not simply each 1800 seconds), so the API ought to fireplace precisely at hh:00 and hh:30.

Utilizing this strategy, the API known as 30–40 instances per minute inside a single view controller. The API name is triggered from a customized navigation bar (ENavigationBar), which is subclass of UIView.

func scheduleFunctionCall() {
    if UIApplication.shared.applicationState == .background { return }

    // We verify the physician appointment the primary time to see if it is out there.
    self.drTimer?.invalidate()
    self.drTimer = nil
    
    if !GlobalConstant.appCONSTANT.isDrAppointmentCheckedFirstTime {
        checkDrAppointmentAvailable()
    } else {
        if GlobalConstant.appCONSTANT.roomName != "" {
            showNeedHelpDrButton()
        } else {
            hideNeedHelpDrView()
        }
    }

    // Get the present time
    let calendar = Calendar.present
    let now = Date()
    let minute = calendar.part(.minute, from: now)
    let second = calendar.part(.second, from: now)
    var fireInSeconds: TimeInterval = 0

    if minute = 31 && minute 

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments