How to register for an event that resembles an application at a specified time in iOS

I have a requirement to initiate synchronization every night at 1:00 or every 2 weeks. How can I achieve this in iOS? Is there a way in iOS that my application can tell me to remind at this time, and my application should be reminded at the specified specific time.

+4
source share
4 answers

Background fetching is an opportunity provided by the OS ( iOS 7 onwards ) for applications that have requested an operation when in the background, however, leaving the OS to decide the time. The OS will quietly wake your application (in fact, the handler method) in the background, learning about the user's use of the application.

Using functions: . At the moment, this feature has been implemented in iOS7 to improve the usability of social networks, newspapers, etc. daily / frequent / heavy content refreshing apps.

Note - this is just a request that is not guaranteed, but an attempt by the base OS to improve the user interface)

In terms of coding / implementation, there are basically 2-3 key steps -

) Background Modes Background Fetch ( " " > "" > " " > " " ) enter image description here

B) -

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0);

C) , , - , appDidFinishLaunchingWithOptions

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];

, -

, / XCode 5+ Debug > Simulate Background Fetch

enter image description here

.

204 Apple WWDC 2013 -

EDIT -

(iOS 7.0.3), , ,

  • BackgroundFetchInterval 5 15 (- , ).
  • , .
  • .

, /.

+3

NSLocalNotification. . ( ):

UILocalNotification *notification = [[UILocalNotification alloc] init];

// Activate in 5 segundos
notification.fireDate = [[NSDate alloc] initWithTimeIntervalSinceNow:5];

// message to show 
notification.alertBody = self.nameTextField.text;

// default sound
notification.soundName = UILocalNotificationDefaultSoundName;

// button title
notification.alertAction = @"Ahora te lo cuento";
notification.hasAction = YES;

// activa la notificación
[[UIApplication sharedApplication] scheduleLocalNotification:notification];

, . , . , .

+1

, Apple Push . WWDC 2013, , , push- , .

, Push-, Apple, , push-, , / NSURLSession, . , , , , , .

, , , , .

0

@Steve - , Apple Push Notifications . EKCalendar, push- / /. didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler , , . : content-availableset to 1. The only drawback is that the timely delivery of remote notifications, which so far during my testing turned out to be about 95 +% effective / accurate, so that within 2-30 + seconds, but I also saw cases where notifications have never been received or> 1-5 + minutes delayed. This is rare for my purposes, acceptable for my application functionality.

0
source

All Articles