Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. Nov 24 16:43:41 my-iPhone locationd[64] <Notice>: client 'com.life360.safetymap' starting significant location changes
  2.  
  3. - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
  4. {
  5. [LogPhoneEvent logPhoneEvent:@"APPLICATION DID FINISH LAUNCHING WITH OPTIONS"];
  6. [LocationManagement startSignificantChangeUpdates];
  7. CGRect screenBounds = [[UIScreen mainScreen] bounds];
  8.  
  9. #if __has_feature(objc_arc)
  10. self.window = [[UIWindow alloc] initWithFrame:screenBounds];
  11. #else
  12. self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
  13. #endif
  14. self.window.autoresizesSubviews = YES;
  15.  
  16. #if __has_feature(objc_arc)
  17. self.viewController = [[MainViewController alloc] init];
  18. #else
  19. self.viewController = [[[MainViewController alloc] init] autorelease];
  20. #endif
  21.  
  22. // Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
  23. // If necessary, uncomment the line below to override it.
  24. // self.viewController.startPage = @"index.html";
  25. self.window.rootViewController = self.viewController;
  26. [self.window makeKeyAndVisible];
  27.  
  28. // NOTE: To customize the view's frame size (which defaults to full screen), override
  29. // [self.viewController viewWillAppear:] in your view controller.
  30. [self.viewController setLaunchOptions:launchOptions];
  31. // }
  32. return YES;
  33. }
  34.  
  35. #import <CoreLocation/CoreLocation.h>
  36. #import "LogPhoneEvent.h"
  37.  
  38. @interface LocationManagement : NSObject <CLLocationManagerDelegate>
  39.  
  40. + (void)startSignificantChangeUpdates;
  41. + (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;
  42. + (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
  43.  
  44. @end
  45.  
  46. //
  47. // LocationManagement.m
  48. //
  49.  
  50. #import "LocationManagement.h"
  51.  
  52.  
  53. @implementation LocationManagement
  54.  
  55. CLLocationManager* locationManager;
  56. #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
  57. #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
  58. #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  59. #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
  60. #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
  61.  
  62. + (void)startSignificantChangeUpdates
  63. {
  64. // Create the location manager if this object does not
  65. // already have one.
  66. NSLog(@"LocationManagement attempting startSignificantChangeUpdates");
  67.  
  68. if (nil == locationManager){
  69. locationManager = [[CLLocationManager alloc] init];
  70. [LogPhoneEvent logPhoneEvent:[NSString stringWithFormat:@"startSignificantChangeUpdates creating new CLLocationManager"]];
  71. }
  72. [locationManager setDelegate:(id)self];
  73.  
  74. if ([CLLocationManager significantLocationChangeMonitoringAvailable]){
  75. NSLog(@"LocationManagement significantLocationChangeMonitoring IS AVAILABLE");
  76. if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0.0")){
  77. if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
  78. {
  79. [locationManager requestAlwaysAuthorization];
  80. }
  81. }
  82. [LogPhoneEvent logPhoneEvent:[NSString stringWithFormat:@"startSignificantChangeUpdates START MONITORING SIGNIFICANT LOCATION CHANGES"]];
  83. [locationManager startMonitoringSignificantLocationChanges];
  84. //[locationManager startUpdatingLocation];
  85. NSLog(@"my-uBox LocationManagement starting significant change updates");
  86. }
  87. else{
  88. [LogPhoneEvent logPhoneEvent:[NSString stringWithFormat:@"startSignificantChangeUpdates significantLocationChangeMonitoring NOT AVAILABLE"]];
  89. NSLog(@"my-uBox LocationManagement significantLocationChangeMonitoring NOT AVAILABLE");
  90. }
  91. }
  92.  
  93. +(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
  94. CLLocation *newLocation = [locations lastObject];
  95. [LogPhoneEvent logPhoneEvent:[NSString stringWithFormat:@"locationmanager DID UPDATE LOCATION to %@", newLocation]];
  96. NSLog(@"LocationManagement didUpdateLocations to %@", newLocation);
  97. }
  98.  
  99. +(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
  100. NSLog(@"LocationManagement didFailWithError %@", error);
  101. [LogPhoneEvent logPhoneEvent:[NSString stringWithFormat:@"locationmanager DID FAIL WITH ERROR %@", error]];
  102. }
  103.  
  104. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement