But when I set the date in the date picker and close the app, the notification doesn't appear.I already enabled Push Notifications in my provisioning profiles.
None) health Manager.health Kit Store.execute Query(squery) Cannot find an initializer for type 'HKStatistics Query' that accepts an argument list of type '(quantity Type: HKSample Type, quantity Sample Predicate: NSPredicate, options: HKStatistics Options, (_, _, _) -let health: HKHealth Store = HKHealth Store() let heart Rate Unit: HKUnit = HKUnit(from String: "count/min") let heart Rate Type: HKQuantity Type = HKQuantity Type.quantity Type For Identifier(HKQuantity Type Identifier Heart Rate)! /*Method to get todays heart rate - this only reads data from health kit.
From an Apple example here’s how you normalize to midnight today’s date, do the same for the second date and compare: NSCalendar * gregorian = NSCalendar alloc] init With Calendar Identifier: NSGregorian Calendar]; NSDate Components * components = [gregorian components: (NSYear Calendar Unit|NSMonth Calendar Unit|NSDay Calendar Unit) from Date:[NSDate date; NSDate * today = [gregorian date From Components:components]; No need to juggle with components, eras and stuff. I am leaving this answer as is so that if someone is looking for something similar and [my Date time Interval Since Now] is useful, they may find it here.NSCalendar provides an method to get the beginning of a certain time unit for an existing date. Day], from Date: NSDate()) let today = From Components(components)! NSDate *base Date = [NSDate date]; NSArray *dates To Compare = [NSArray array With Objects:[NSDate date], [NSDate date With Time Interval Since Now:100], [NSDate date With Time Interval Since Now:1000], [NSDate date With Time Interval Since Now:-10000], [NSDate date With Time Interval Since Now:100000], [NSDate date With Time Interval Since Now:1000000], [NSDate date With Time Interval Since Now:50], nil]; // determine the NSDate for midnight of the base date: NSCalendar* calendar = [NSCalendar current Calendar]; NSDate Components* comps = [calendar components:(NSYear Calendar Unit|NSMonth Calendar Unit|NSDay Calendar Unit) from Date:base Date]; NSDate* the Midnight Hour = [calendar date From Components:comps]; // set up a localized date formatter so we can see the answers are right!Since Cocoa implements time according to the NTP standard, these methods ignore leap seconds in the calculation.You use parameter corresponds to Jan 15, 2010 at AM, there are only 8.5 hours between the two dates.]]