I'm having trouble converting NSDate date to local DateTime. I'm using Local Notifications and my fireDate property is ok except UTC component in my date.
This is NSDate date and converted date to my local timezone
This is my conversion code as found here Convert UTC NSDate to local Timezone Objective-C
NSDate *someDateInUTC = [NSDate date];
NSTimeInterval timeZoneSeconds = [[NSTimeZone localTimeZone] secondsFromGMT];
NSDate *dateInLocalTimezone = [someDateInUTC dateByAddingTimeInterval:timeZoneSeconds];
I'm adding five seconds to my time component so this is my fireDate:
I'm using push notifications and when the user is somewhere in the app, I want to present him local notification from my push notification. This code is in my - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
method. I've implemented method for local notifications:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIApplicationState applicationState = application.applicationState;
if (applicationState == UIApplicationStateBackground) {
[application presentLocalNotificationNow:notification];
}
}
I'm thinking that this UTC component in my dateInLocalTimezone is causing my trouble but I don't know how to solve it.