mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This patch changes the default `flutter create` command to generate a HelloServices-style app on iOS. As a consequence, the Atom integration now fully works with HelloServices.
40 lines
1.1 KiB
Objective-C
40 lines
1.1 KiB
Objective-C
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#import "LocationProvider.h"
|
|
|
|
#import <CoreLocation/CoreLocation.h>
|
|
|
|
@implementation LocationProvider {
|
|
CLLocationManager* _locationManager;
|
|
}
|
|
|
|
@synthesize messageName = _messageName;
|
|
|
|
- (instancetype) init {
|
|
self = [super init];
|
|
if (self)
|
|
self->_messageName = @"getLocation";
|
|
return self;
|
|
}
|
|
|
|
- (NSString*)didReceiveString:(NSString*)message {
|
|
if (_locationManager == nil) {
|
|
_locationManager = [[CLLocationManager alloc] init];
|
|
[_locationManager startMonitoringSignificantLocationChanges];
|
|
}
|
|
|
|
CLLocation* location = _locationManager.location;
|
|
|
|
NSDictionary* response = @{
|
|
@"latitude": @(location.coordinate.latitude),
|
|
@"longitude": @(location.coordinate.longitude),
|
|
};
|
|
|
|
NSData* data = [NSJSONSerialization dataWithJSONObject:response options:0 error:nil];
|
|
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
}
|
|
|
|
@end
|