CDVLocation.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. #import <UIKit/UIKit.h>
  18. #import <CoreLocation/CoreLocation.h>
  19. #import <Cordova/CDVPlugin.h>
  20. enum CDVLocationStatus {
  21. PERMISSIONDENIED = 1,
  22. POSITIONUNAVAILABLE,
  23. TIMEOUT
  24. };
  25. typedef NSUInteger CDVLocationStatus;
  26. // simple object to keep track of location information
  27. @interface CDVLocationData : NSObject {
  28. CDVLocationStatus locationStatus;
  29. NSMutableArray* locationCallbacks;
  30. NSMutableDictionary* watchCallbacks;
  31. CLLocation* locationInfo;
  32. }
  33. @property (nonatomic, assign) CDVLocationStatus locationStatus;
  34. @property (nonatomic, strong) CLLocation* locationInfo;
  35. @property (nonatomic, strong) NSMutableArray* locationCallbacks;
  36. @property (nonatomic, strong) NSMutableDictionary* watchCallbacks;
  37. @end
  38. @interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{
  39. @private BOOL __locationStarted;
  40. @private BOOL __highAccuracyEnabled;
  41. CDVLocationData* locationData;
  42. }
  43. @property (nonatomic, strong) CLLocationManager* locationManager;
  44. @property (nonatomic, strong) CDVLocationData* locationData;
  45. - (void)getLocation:(CDVInvokedUrlCommand*)command;
  46. - (void)addWatch:(CDVInvokedUrlCommand*)command;
  47. - (void)clearWatch:(CDVInvokedUrlCommand*)command;
  48. - (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback;
  49. - (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message;
  50. - (void)startLocation:(BOOL)enableHighAccuracy;
  51. - (void)locationManager:(CLLocationManager*)manager
  52. didUpdateToLocation:(CLLocation*)newLocation
  53. fromLocation:(CLLocation*)oldLocation;
  54. - (void)locationManager:(CLLocationManager*)manager
  55. didFailWithError:(NSError*)error;
  56. - (BOOL)isLocationServicesEnabled;
  57. @end