From a3ca335425dd6f25f0f772438aa9eb0f2178be0c Mon Sep 17 00:00:00 2001 From: "Kresten P. Vester" Date: Thu, 10 Oct 2019 08:56:38 +0200 Subject: [PATCH 01/13] Upgrade to avoid build errors/warnings --- android/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 336dfe07..9f36f75c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'io.flutter.plugins.geofencing' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.0' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.android.tools.build:gradle:3.5.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -41,5 +41,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "com.google.android.gms:play-services-location:16.+" + implementation "com.google.android.gms:play-services-location:17.+" } From b7f9a0945cec6d0c416f54845ced596315693abc Mon Sep 17 00:00:00 2001 From: "Kresten P. Vester" Date: Thu, 17 Oct 2019 15:23:20 +0200 Subject: [PATCH 02/13] Execute on UIThread --- .../io/flutter/plugins/geofencing/GeofencingService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt index d0ce7188..150cdb85 100644 --- a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt +++ b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt @@ -6,8 +6,9 @@ package io.flutter.plugins.geofencing import android.content.Context import android.content.Intent -import androidx.core.app.JobIntentService +import android.os.Handler import android.util.Log +import androidx.core.app.JobIntentService import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.Result @@ -144,7 +145,7 @@ class GeofencingService : MethodCallHandler, JobIntentService() { queue.add(geofenceUpdateList) } else { // Callback method name is intentionally left blank. - mBackgroundChannel.invokeMethod("", geofenceUpdateList) + Handler(mContext.mainLooper).post { mBackgroundChannel.invokeMethod("", geofenceUpdateList) } } } } From 6c5096f8973ccc9ca325a07eaafb6431a2cb7441 Mon Sep 17 00:00:00 2001 From: "Kresten P. Vester" Date: Fri, 18 Oct 2019 14:54:36 +0200 Subject: [PATCH 03/13] Point to the current plugin --- example/pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a9be8323..b50b1014 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,8 @@ version: 1.0.0+1 dependencies: flutter: sdk: flutter - flutter_geofencing: ^0.0.1 + flutter_geofencing: + path: ../ # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From 4b7cd977fb8ef79a15182754aa1b6dc22263a8ea Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 07:39:42 +0200 Subject: [PATCH 04/13] merge swift v1 --- geofencing.iml => flutter_geofencing.iml | 0 ios/.gitignore | 1 + ios/Classes/FlutterGeofencingPlugin.h | 4 + ios/Classes/FlutterGeofencingPlugin.m | 8 + ios/Classes/GeofencingPlugin.h | 11 - ios/Classes/GeofencingPlugin.m | 255 ------------------ .../SwiftFlutterGeofencingPlugin.swift | 130 +++++++++ ...ing.podspec => flutter_geofencing.podspec} | 4 +- lib/src/geofencing.dart | 1 + 9 files changed, 146 insertions(+), 268 deletions(-) rename geofencing.iml => flutter_geofencing.iml (100%) create mode 100644 ios/Classes/FlutterGeofencingPlugin.h create mode 100644 ios/Classes/FlutterGeofencingPlugin.m delete mode 100644 ios/Classes/GeofencingPlugin.h delete mode 100644 ios/Classes/GeofencingPlugin.m create mode 100644 ios/Classes/SwiftFlutterGeofencingPlugin.swift rename ios/{geofencing.podspec => flutter_geofencing.podspec} (93%) diff --git a/geofencing.iml b/flutter_geofencing.iml similarity index 100% rename from geofencing.iml rename to flutter_geofencing.iml diff --git a/ios/.gitignore b/ios/.gitignore index 710ec6cf..aa479fd3 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -34,3 +34,4 @@ Icon? .tags* /Flutter/Generated.xcconfig +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Classes/FlutterGeofencingPlugin.h b/ios/Classes/FlutterGeofencingPlugin.h new file mode 100644 index 00000000..6460d248 --- /dev/null +++ b/ios/Classes/FlutterGeofencingPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface FlutterGeofencingPlugin : NSObject +@end diff --git a/ios/Classes/FlutterGeofencingPlugin.m b/ios/Classes/FlutterGeofencingPlugin.m new file mode 100644 index 00000000..e6f90254 --- /dev/null +++ b/ios/Classes/FlutterGeofencingPlugin.m @@ -0,0 +1,8 @@ +#import "FlutterGeofencingPlugin.h" +#import + +@implementation FlutterGeofencingPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftFlutterGeofencingPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/ios/Classes/GeofencingPlugin.h b/ios/Classes/GeofencingPlugin.h deleted file mode 100644 index bb491f55..00000000 --- a/ios/Classes/GeofencingPlugin.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GeofencingPlugin_h -#define GeofencingPlugin_h - -#import - -#import - -@interface GeofencingPlugin : NSObject - -@end -#endif diff --git a/ios/Classes/GeofencingPlugin.m b/ios/Classes/GeofencingPlugin.m deleted file mode 100644 index 2edb60f9..00000000 --- a/ios/Classes/GeofencingPlugin.m +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2018 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 "GeofencingPlugin.h" - -#import - -@implementation GeofencingPlugin { - CLLocationManager *_locationManager; - FlutterEngine *_headlessRunner; - FlutterMethodChannel *_callbackChannel; - FlutterMethodChannel *_mainChannel; - NSObject *_registrar; - NSUserDefaults *_persistentState; - NSMutableArray *_eventQueue; - int64_t _onLocationUpdateHandle; -} - -static const NSString *kRegionKey = @"region"; -static const NSString *kEventType = @"event_type"; -static const int kEnterEvent = 1; -static const int kExitEvent = 2; -static const NSString *kCallbackMapping = @"geofence_region_callback_mapping"; -static GeofencingPlugin *instance = nil; -static FlutterPluginRegistrantCallback registerPlugins = nil; -static BOOL initialized = NO; - -#pragma mark FlutterPlugin Methods - -+ (void)registerWithRegistrar:(NSObject *)registrar { - @synchronized(self) { - if (instance == nil) { - instance = [[GeofencingPlugin alloc] init:registrar]; - [registrar addApplicationDelegate:instance]; - } - } -} - -+ (void)setPluginRegistrantCallback:(FlutterPluginRegistrantCallback)callback { - registerPlugins = callback; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - NSArray *arguments = call.arguments; - if ([@"GeofencingPlugin.initializeService" isEqualToString:call.method]) { - NSAssert(arguments.count == 1, - @"Invalid argument count for 'GeofencingPlugin.initializeService'"); - [self startGeofencingService:[arguments[0] longValue]]; - result(@(YES)); - } else if ([@"GeofencingService.initialized" isEqualToString:call.method]) { - @synchronized(self) { - initialized = YES; - // Send the geofence events that occurred while the background - // isolate was initializing. - while ([_eventQueue count] > 0) { - NSDictionary* event = _eventQueue[0]; - [_eventQueue removeObjectAtIndex:0]; - CLRegion* region = [event objectForKey:kRegionKey]; - int type = [[event objectForKey:kEventType] intValue]; - [self sendLocationEvent:region eventType: type]; - } - } - result(nil); - } else if ([@"GeofencingPlugin.registerGeofence" isEqualToString:call.method]) { - [self registerGeofence:arguments]; - result(@(YES)); - } else if ([@"GeofencingPlugin.removeGeofence" isEqualToString:call.method]) { - result(@([self removeGeofence:arguments])); - } else { - result(FlutterMethodNotImplemented); - } -} - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Check to see if we're being launched due to a location event. - if (launchOptions[UIApplicationLaunchOptionsLocationKey] != nil) { - // Restart the headless service. - [self startGeofencingService:[self getCallbackDispatcherHandle]]; - } - - // Note: if we return NO, this vetos the launch of the application. - return YES; -} - -#pragma mark LocationManagerDelegate Methods -- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { - @synchronized(self) { - if (initialized) { - [self sendLocationEvent:region eventType:kEnterEvent]; - } else { - NSDictionary *dict = @{ - kRegionKey: region, - kEventType: @(kEnterEvent) - }; - [_eventQueue addObject:dict]; - } - } -} - -- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { - @synchronized(self) { - if (initialized) { - [self sendLocationEvent:region eventType:kExitEvent]; - } else { - NSDictionary *dict = @{ - kRegionKey: region, - kEventType: @(kExitEvent) - }; - [_eventQueue addObject:dict]; - } - } -} - -- (void)locationManager:(CLLocationManager *)manager - monitoringDidFailForRegion:(CLRegion *)region - withError:(NSError *)error { -} - -#pragma mark GeofencingPlugin Methods - -- (void)sendLocationEvent:(CLRegion *)region eventType:(int)event { - NSAssert([region isKindOfClass:[CLCircularRegion class]], @"region must be CLCircularRegion"); - CLLocationCoordinate2D center = region.center; - int64_t handle = [self getCallbackHandleForRegionId:region.identifier]; - [_callbackChannel - invokeMethod:@"" - arguments:@[ - @(handle), @[ region.identifier ], @[ @(center.latitude), @(center.longitude) ], @(event) - ]]; -} - -- (instancetype)init:(NSObject *)registrar { - self = [super init]; - NSAssert(self, @"super init cannot be nil"); - _persistentState = [NSUserDefaults standardUserDefaults]; - _eventQueue = [[NSMutableArray alloc] init]; - _locationManager = [[CLLocationManager alloc] init]; - [_locationManager setDelegate:self]; - [_locationManager requestAlwaysAuthorization]; - _locationManager.allowsBackgroundLocationUpdates = YES; - - _headlessRunner = [[FlutterEngine alloc] initWithName:@"GeofencingIsolate" project:nil allowHeadlessExecution:YES]; - _registrar = registrar; - - _mainChannel = [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/geofencing_plugin" - binaryMessenger:[registrar messenger]]; - [registrar addMethodCallDelegate:self channel:_mainChannel]; - - _callbackChannel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/geofencing_plugin_background" - binaryMessenger:_headlessRunner]; - return self; -} - -- (void)startGeofencingService:(int64_t)handle { - [self setCallbackDispatcherHandle:handle]; - FlutterCallbackInformation *info = [FlutterCallbackCache lookupCallbackInformation:handle]; - NSAssert(info != nil, @"failed to find callback"); - NSString *entrypoint = info.callbackName; - NSString *uri = info.callbackLibraryPath; - [_headlessRunner runWithEntrypoint:entrypoint libraryURI:uri]; - NSAssert(registerPlugins != nil, @"failed to set registerPlugins"); - - // Once our headless runner has been started, we need to register the application's plugins - // with the runner in order for them to work on the background isolate. `registerPlugins` is - // a callback set from AppDelegate.m in the main application. This callback should register - // all relevant plugins (excluding those which require UI). - registerPlugins(_headlessRunner); - [_registrar addMethodCallDelegate:self channel:_callbackChannel]; -} - -- (void)registerGeofence:(NSArray *)arguments { - int64_t callbackHandle = [arguments[0] longLongValue]; - NSString *identifier = arguments[1]; - double latitude = [arguments[2] doubleValue]; - double longitude = [arguments[3] doubleValue]; - double radius = [arguments[4] doubleValue]; - int64_t triggerMask = [arguments[5] longLongValue]; - - CLCircularRegion *region = - [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(latitude, longitude) - radius:radius - identifier:identifier]; - region.notifyOnEntry = ((triggerMask & 0x1) != 0); - region.notifyOnExit = ((triggerMask & 0x2) != 0); - - [self setCallbackHandleForRegionId:callbackHandle regionId:identifier]; - [self->_locationManager startMonitoringForRegion:region]; -} - -- (BOOL)removeGeofence:(NSArray *)arguments { - NSString *identifier = arguments[0]; - for (CLRegion *region in [self->_locationManager monitoredRegions]) { - if ([region.identifier isEqual:identifier]) { - [self->_locationManager stopMonitoringForRegion:region]; - [self removeCallbackHandleForRegionId:identifier]; - return YES; - } - } - return NO; -} - -- (int64_t)getCallbackDispatcherHandle { - id handle = [_persistentState objectForKey:@"callback_dispatcher_handle"]; - if (handle == nil) { - return 0; - } - return [handle longLongValue]; -} - -- (void)setCallbackDispatcherHandle:(int64_t)handle { - [_persistentState setObject:[NSNumber numberWithLongLong:handle] - forKey:@"callback_dispatcher_handle"]; -} - -- (NSMutableDictionary *)getRegionCallbackMapping { - const NSString *key = kCallbackMapping; - NSMutableDictionary *callbackDict = [_persistentState dictionaryForKey:key]; - if (callbackDict == nil) { - callbackDict = @{}; - [_persistentState setObject:callbackDict forKey:key]; - } - return [callbackDict mutableCopy]; -} - -- (void)setRegionCallbackMapping:(NSMutableDictionary *)mapping { - const NSString *key = kCallbackMapping; - NSAssert(mapping != nil, @"mapping cannot be nil"); - [_persistentState setObject:mapping forKey:key]; -} - -- (int64_t)getCallbackHandleForRegionId:(NSString *)identifier { - NSMutableDictionary *mapping = [self getRegionCallbackMapping]; - id handle = [mapping objectForKey:identifier]; - if (handle == nil) { - return 0; - } - return [handle longLongValue]; -} - -- (void)setCallbackHandleForRegionId:(int64_t)handle regionId:(NSString *)identifier { - NSMutableDictionary *mapping = [self getRegionCallbackMapping]; - [mapping setObject:[NSNumber numberWithLongLong:handle] forKey:identifier]; - [self setRegionCallbackMapping:mapping]; -} - -- (void)removeCallbackHandleForRegionId:(NSString *)identifier { - NSMutableDictionary *mapping = [self getRegionCallbackMapping]; - [mapping removeObjectForKey:identifier]; - [self setRegionCallbackMapping:mapping]; -} - -@end diff --git a/ios/Classes/SwiftFlutterGeofencingPlugin.swift b/ios/Classes/SwiftFlutterGeofencingPlugin.swift new file mode 100644 index 00000000..41548496 --- /dev/null +++ b/ios/Classes/SwiftFlutterGeofencingPlugin.swift @@ -0,0 +1,130 @@ +import Flutter +import UIKit +import CoreLocation + +class FLGeofence { + var callback: Int + var lat: String + var long: String + var id: String + + init(callback: Int, id: String, lat: String, long: String) { + self.callback = callback + self.lat = lat + self.long = long + self.id = id + } +} +public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationManagerDelegate { + var flGeofences: [FLGeofence] = [] + + private var locationManager: CLLocationManager = CLLocationManager() + var callBackHandler: FlutterMethodChannel? + private var distanceOnGeolocation = 1500.0 + + public static func register(with registrar: FlutterPluginRegistrar) { + let instance = SwiftFlutterGeofencingPlugin() + instance.setupCallHandler(registrar: registrar) + instance.callBackHandler = FlutterMethodChannel(name: "plugins.flutter.io/geofencing_plugin_background", binaryMessenger: registrar.messenger()) + } + + func setupCallHandler(registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "plugins.flutter.io/geofencing_plugin", binaryMessenger: registrar.messenger()) + channel.setMethodCallHandler { (call: FlutterMethodCall, result: FlutterResult) in + // Ask for permission + if call.method == "GeofencingPlugin.initializeService" { + result("iOS " + UIDevice.current.systemVersion) + self.locationManager.delegate = self + self.locationManager.requestAlwaysAuthorization() + let resultMap: [String: String] = [:] + + result(resultMap) + } else if call.method == "GeofencingPlugin.registerGeofence" { + if let nsArray = call.arguments as? NSArray { + let callbackHandle = nsArray[0] as? Int + let id = nsArray[1] as? String + let lat = nsArray[2] as? Double + let long = nsArray[3] as? Double + if let id = id, let lat = lat, let long = long { + let flGeofence: FLGeofence = FLGeofence(callback: callbackHandle ?? 0, id: id, lat: lat.description, long: long.description) + self.register(flGeofenceList: [flGeofence]) + self.invoke(event: 1, region: nil) + } + } + let resultMap: [String: String] = [:] + result(resultMap) + } else if call.method == "GeofencingPlugin.removeGeofence" { + self.removeRegionMonitering() + let resultMap: [String: String] = [:] + result(resultMap) + } + } + } + + func register(flGeofenceList: [FLGeofence]) -> Void { + let currentLocation: CLLocation = self.locationManager.location ?? CLLocation(latitude: 0, longitude: 0) + flGeofences = flGeofenceList + + // Apple only support 20 region locations for the same app + if flGeofences.count > 20 { + flGeofences.sort { (a, b) -> Bool in + let latA = Double(a.lat) ?? 0 + let longA = Double(a.long) ?? 0 + let latB = Double(b.lat) ?? 0 + let longB = Double(b.long) ?? 0 + return CLLocation(latitude: latA, longitude: longA).distance(from: currentLocation) < CLLocation(latitude: latB, longitude: longB).distance(from: currentLocation) + } + + flGeofences = flGeofences.enumerated().compactMap{ $0.offset < 19 ? $0.element : nil } + } + + // Subscribing to geofence with the location list + for location in flGeofences { + let lat = Double(location.lat) ?? 0 + let long = Double(location.long) ?? 0 + let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: lat, longitude: long), radius: distanceOnGeolocation, identifier: location.id) + region.notifyOnExit = true + region.notifyOnEntry = true + + self.locationManager.startMonitoring(for: region) + } + } + + public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { + invoke(event: 1, region: region) + } + + public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { + invoke(event: 2, region: region) + } + + func removeRegionMonitering() { + let regions = locationManager.monitoredRegions + + for region in regions { + locationManager.stopMonitoring(for: region) + } + } + + func invoke(event: Int, region: CLRegion?) { + let geofence = flGeofences.first { (g) in + if g.id == "de gamle" { + return true + } + return false + } + + if let geofence = geofence { + var args: [Any] = [] + args.append(geofence.callback) // callback Int + + args.append([geofence.id]) // triggeringGeofences List ids + + args.append([Double(geofence.lat) ?? 0.0, Double(geofence.long) ?? 0.0]) // locationList List long lat + + args.append(event) // _kEnterEvent = 1 / _kExitEvent = 2 + + callBackHandler?.invokeMethod("", arguments: args) + } + } +} diff --git a/ios/geofencing.podspec b/ios/flutter_geofencing.podspec similarity index 93% rename from ios/geofencing.podspec rename to ios/flutter_geofencing.podspec index 6c29211d..e549ba2f 100644 --- a/ios/geofencing.podspec +++ b/ios/flutter_geofencing.podspec @@ -2,7 +2,7 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| - s.name = 'geofencing' + s.name = 'flutter_geofencing' s.version = '0.0.1' s.summary = 'A new flutter plugin project.' s.description = <<-DESC @@ -15,7 +15,7 @@ A new flutter plugin project. s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - + s.ios.deployment_target = '8.0' end diff --git a/lib/src/geofencing.dart b/lib/src/geofencing.dart index 40e7fd91..9f919400 100644 --- a/lib/src/geofencing.dart +++ b/lib/src/geofencing.dart @@ -146,6 +146,7 @@ class GeofencingManager { PluginUtilities.getCallbackHandle(callback).toRawHandle() ]; args.addAll(region._toArgs()); + callbackDispatcher(); await _channel.invokeMethod('GeofencingPlugin.registerGeofence', args); } From 9fbedae512ee74e6ababa8b93b71d8b35ab2f1b2 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 07:56:10 +0200 Subject: [PATCH 05/13] merge swift v2 --- CHANGELOG.md | 2 +- LICENSE | 6 +- README.md | 117 +---------- example/.gitignore | 70 ++++++- example/.idea/libraries/Dart_SDK.xml | 19 -- .../.idea/libraries/Flutter_for_Android.xml | 9 - example/.idea/modules.xml | 9 - example/.metadata | 6 +- example/README.md | 16 +- ...ple.iml => flutter_geofencing_example.iml} | 0 example/geofencing_example_android.iml | 27 --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 16 +- example/ios/Podfile.lock | 26 +-- example/ios/Runner.xcodeproj/project.pbxproj | 192 +++++++++++++----- .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../xcshareddata/xcschemes/Runner.xcscheme | 4 +- example/ios/Runner/AppDelegate.h | 6 - example/ios/Runner/AppDelegate.m | 21 -- example/ios/Runner/AppDelegate.swift | 13 ++ .../Icon-App-1024x1024@1x.png | Bin 11112 -> 0 bytes .../ios/Runner/GeneratedPluginRegistrant.h | 14 ++ .../ios/Runner/GeneratedPluginRegistrant.m | 14 ++ example/ios/Runner/Info.plist | 40 ++-- example/ios/Runner/Runner-Bridging-Header.h | 1 + example/ios/Runner/main.m | 9 - example/pubspec.yaml | 27 ++- flutter_geofencing.iml | 2 +- lib/src/callback_dispatcher.dart | 1 - pubspec.yaml | 57 +++++- 30 files changed, 394 insertions(+), 340 deletions(-) delete mode 100644 example/.idea/libraries/Dart_SDK.xml delete mode 100644 example/.idea/libraries/Flutter_for_Android.xml delete mode 100644 example/.idea/modules.xml rename example/{geofencing_example.iml => flutter_geofencing_example.iml} (100%) delete mode 100644 example/geofencing_example_android.iml delete mode 100644 example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 example/ios/Runner/AppDelegate.h delete mode 100644 example/ios/Runner/AppDelegate.m create mode 100644 example/ios/Runner/AppDelegate.swift delete mode 100644 example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png create mode 100644 example/ios/Runner/GeneratedPluginRegistrant.h create mode 100644 example/ios/Runner/GeneratedPluginRegistrant.m create mode 100644 example/ios/Runner/Runner-Bridging-Header.h delete mode 100644 example/ios/Runner/main.m diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ae0560..41cc7d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -## 0.1.2 +## 0.0.1 * TODO: Describe initial release. diff --git a/LICENSE b/LICENSE index e662c786..ba75c69f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1 @@ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +TODO: Add your license here. diff --git a/README.md b/README.md index a8d3de66..3b49053b 100644 --- a/README.md +++ b/README.md @@ -1,113 +1,14 @@ -What is geofencing? -[here](https://developer.android.com/training/location/geofencing) +# flutter_geofencing -This is based on Ben Konyi geofencing library, supporting AndroidX -Following is the documentation provided by him - -# Geofencing - -A sample geofencing plugin with background execution support for Flutter. +A new flutter plugin project. ## Getting Started -This plugin works on both Android and iOS. Follow the instructions in the following sections for the -platforms which are to be targeted. - -### Android - -Add the following lines to your `AndroidManifest.xml` to register the background service for -geofencing: - -```xml - - -``` - -Also request the correct permissions for geofencing: - -```xml - -``` - -Finally, create either `Application.kt` or `Application.java` in the same directory as `MainActivity`. - -For `Application.kt`, use the following: - -```kotlin -class Application : FlutterApplication(), PluginRegistrantCallback { - override fun onCreate() { - super.onCreate(); - GeofencingService.setPluginRegistrant(this); - } - - override fun registerWith(registry: PluginRegistry) { - GeneratedPluginRegistrant.registerWith(registry); - } -} -``` - -For `Application.java`, use the following: - -```java -public class Application extends FlutterApplication implements PluginRegistrantCallback { - @Override - public void onCreate() { - super.onCreate(); - GeofencingService.setPluginRegistrant(this); - } - - @Override - public void registerWith(PluginRegistry registry) { - GeneratedPluginRegistrant.registerWith(registry); - } -} -``` - -Which must also be referenced in `AndroidManifest.xml`: - -```xml - - NSLocationAlwaysAndWhenInUseUsageDescription - YOUR DESCRIPTION HERE - NSLocationWhenInUseUsageDescription - YOUR DESCRIPTION HERE - ... -``` - -And request the correct permissions for geofencing: - -```xml - - ... - Main - UIRequiredDeviceCapabilities - - location-services - gps - armv7 - - UIBackgroundModes - - location - - ... - -``` - -### Need Help? -For help getting started with Flutter, view our online -[documentation](https://flutter.io/). +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. -For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package). +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/.gitignore b/example/.gitignore index dee655cc..2ddde2a5 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,9 +1,73 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp .DS_Store -.dart_tool/ +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins .packages +.pub-cache/ .pub/ +/build/ -build/ +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java -.flutter-plugins +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/example/.idea/libraries/Dart_SDK.xml b/example/.idea/libraries/Dart_SDK.xml deleted file mode 100644 index b196fc36..00000000 --- a/example/.idea/libraries/Dart_SDK.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/.idea/libraries/Flutter_for_Android.xml b/example/.idea/libraries/Flutter_for_Android.xml deleted file mode 100644 index 1d58969e..00000000 --- a/example/.idea/libraries/Flutter_for_Android.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/example/.idea/modules.xml b/example/.idea/modules.xml deleted file mode 100644 index 3e2f984d..00000000 --- a/example/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/example/.metadata b/example/.metadata index 94aa1505..65686a2d 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,5 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 7762e451159823e2c605c8f444f7b4f5b2f3784f - channel: master + revision: cc949a8e8b9cf394b9290a8e80f87af3e207dce5 + channel: stable + +project_type: app diff --git a/example/README.md b/example/README.md index 097a88d1..c5d1651e 100644 --- a/example/README.md +++ b/example/README.md @@ -1,8 +1,16 @@ -# geofencing_example +# flutter_geofencing_example -Demonstrates how to use the geofencing plugin. +Demonstrates how to use the flutter_geofencing plugin. ## Getting Started -For help getting started with Flutter, view our online -[documentation](https://flutter.io/). +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/geofencing_example.iml b/example/flutter_geofencing_example.iml similarity index 100% rename from example/geofencing_example.iml rename to example/flutter_geofencing_example.iml diff --git a/example/geofencing_example_android.iml b/example/geofencing_example_android.iml deleted file mode 100644 index b050030a..00000000 --- a/example/geofencing_example_android.iml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d483..6b4c0f78 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable App CFBundleIdentifier diff --git a/example/ios/Podfile b/example/ios/Podfile index 7c6cb6f6..e5e1440b 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,9 +1,18 @@ +# Using a CDN with CocoaPods 1.7.2 or later can save a lot of time on pod installation, but it's experimental rather than the default. +# source 'https://cdn.cocoapods.org/' + # Uncomment this line to define a global platform for your project # platform :ios, '9.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + def parse_KV_file(file, separator='=') file_abs_path = File.expand_path(file) if !File.exists? file_abs_path @@ -27,6 +36,8 @@ def parse_KV_file(file, separator='=') end target 'Runner' do + use_frameworks! + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # referring to absolute paths on developers' machines. system('rm -rf .symlinks') @@ -35,7 +46,7 @@ target 'Runner' do # Flutter Pods generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." end generated_xcode_build_settings.map { |p| if p[:name] == 'FLUTTER_FRAMEWORK_DIR' @@ -54,6 +65,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index dd01b916..cba34aef 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,28 +1,22 @@ PODS: - Flutter (1.0.0) - - flutter_local_notifications (0.0.1): - - Flutter - - geofencing (0.0.1): + - flutter_geofencing (0.0.1): - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios_debug_sim`) - - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - - geofencing (from `.symlinks/plugins/geofencing/ios`) + - Flutter (from `.symlinks/flutter/ios`) + - flutter_geofencing (from `.symlinks/plugins/flutter_geofencing/ios`) EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios_debug_sim" - flutter_local_notifications: - :path: ".symlinks/plugins/flutter_local_notifications/ios" - geofencing: - :path: ".symlinks/plugins/geofencing/ios" + :path: ".symlinks/flutter/ios" + flutter_geofencing: + :path: ".symlinks/plugins/flutter_geofencing/ios" SPEC CHECKSUMS: - Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296 - flutter_local_notifications: 696a74904e0a0ab754e27a5f761da4a7f9153710 - geofencing: 03e5e092597a2619fb90fc277d31932752595b00 + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + flutter_geofencing: cd2342accf22d2b76b3acfdb39ded6bca972d949 -PODFILE CHECKSUM: 1e5af4103afd21ca5ead147d7b81d06f494f51a2 +PODFILE CHECKSUM: 10ae9c18d12c9ffc2275c9a159a3b1e281990db0 -COCOAPODS: 1.5.3 +COCOAPODS: 1.7.4 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 6d3d4025..f823ac2e 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -11,10 +11,11 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 56ABF48AFE7FD71C60234A6C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CF8846826A01BC1D9DE0720 /* Pods_Runner.framework */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 973C541AD22AEBFA99FE6326 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 93ABD7C612988E5FEDAEC874 /* libPods-Runner.a */; }; - 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; - 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -28,6 +29,7 @@ dstSubfolderSpec = 10; files = ( 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -37,21 +39,23 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 1AED559D8E65F2D76C593812 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 5B1CD73AA7A161199DF4DBC8 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 93ABD7C612988E5FEDAEC874 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7CF8846826A01BC1D9DE0720 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AC0D7059DAF720A141EEE5ED /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -61,18 +65,19 @@ files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - 973C541AD22AEBFA99FE6326 /* libPods-Runner.a in Frameworks */, + 56ABF48AFE7FD71C60234A6C /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 6CBC30358DFF51EA0A13FCBB /* Pods */ = { + 060153742B338D5D010A1D2D /* Frameworks */ = { isa = PBXGroup; children = ( + 7CF8846826A01BC1D9DE0720 /* Pods_Runner.framework */, ); - name = Pods; + name = Frameworks; sourceTree = ""; }; 9740EEB11CF90186004384FC /* Flutter */ = { @@ -94,8 +99,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - 6CBC30358DFF51EA0A13FCBB /* Pods */, - BC45E5689E17726DF2ACA24F /* Frameworks */, + 9F30B01EB2BF5301CAD3B0FC /* Pods */, + 060153742B338D5D010A1D2D /* Frameworks */, ); sourceTree = ""; }; @@ -110,8 +115,6 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( - 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, - 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -119,6 +122,8 @@ 97C146F11CF9000F007C117D /* Supporting Files */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, ); path = Runner; sourceTree = ""; @@ -126,17 +131,18 @@ 97C146F11CF9000F007C117D /* Supporting Files */ = { isa = PBXGroup; children = ( - 97C146F21CF9000F007C117D /* main.m */, ); name = "Supporting Files"; sourceTree = ""; }; - BC45E5689E17726DF2ACA24F /* Frameworks */ = { + 9F30B01EB2BF5301CAD3B0FC /* Pods */ = { isa = PBXGroup; children = ( - 93ABD7C612988E5FEDAEC874 /* libPods-Runner.a */, + 5B1CD73AA7A161199DF4DBC8 /* Pods-Runner.debug.xcconfig */, + AC0D7059DAF720A141EEE5ED /* Pods-Runner.release.xcconfig */, + 1AED559D8E65F2D76C593812 /* Pods-Runner.profile.xcconfig */, ); - name = Frameworks; + path = Pods; sourceTree = ""; }; /* End PBXGroup section */ @@ -146,14 +152,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - A382B369948A6D85048CDC2F /* [CP] Check Pods Manifest.lock */, + 4C475267799FF2A3FA2FCBAC /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 96A6A0AE849E95E0E8EFCB70 /* [CP] Embed Pods Frameworks */, + 5115F17CCE34B416F9EEFED0 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -170,18 +176,19 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = U8PR3Q5466; + DevelopmentTeam = EL577W573J; + LastSwiftMigration = 0910; }; }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -204,6 +211,7 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); @@ -226,55 +234,56 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; - 96A6A0AE849E95E0E8EFCB70 /* [CP] Embed Pods Frameworks */ = { + 4C475267799FF2A3FA2FCBAC /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios_debug_sim/Flutter.framework", + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( ); - name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9740EEB61CF901F6004384FC /* Run Script */ = { + 5115F17CCE34B416F9EEFED0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Run Script"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; }; - A382B369948A6D85048CDC2F /* [CP] Check Pods Manifest.lock */ = { + 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", ); - name = "[CP] Check Pods Manifest.lock"; + name = "Run Script"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; /* End PBXShellScriptBuildPhase section */ @@ -283,8 +292,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, - 97C146F31CF9000F007C117D /* main.m in Sources */, + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -311,6 +319,84 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = 1.0.0.1; + DEVELOPMENT_TEAM = EL577W573J; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterGeofencingExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 4.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; @@ -412,6 +498,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -422,8 +509,9 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = U8PR3Q5466; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = 1.0.0.1; + DEVELOPMENT_TEAM = EL577W573J; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -435,8 +523,12 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.geofencing; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterGeofencingExample; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -446,8 +538,9 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = U8PR3Q5466; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = 1.0.0.1; + DEVELOPMENT_TEAM = EL577W573J; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -459,8 +552,11 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.geofencing; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterGeofencingExample; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -473,6 +569,7 @@ buildConfigurations = ( 97C147031CF9000F007C117D /* Debug */, 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -482,6 +579,7 @@ buildConfigurations = ( 97C147061CF9000F007C117D /* Debug */, 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ba1a9822..a28140cf 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ -#import - -@interface AppDelegate : FlutterAppDelegate - -@end diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m deleted file mode 100644 index 7d6a6074..00000000 --- a/example/ios/Runner/AppDelegate.m +++ /dev/null @@ -1,21 +0,0 @@ -#include "AppDelegate.h" -#include "GeneratedPluginRegistrant.h" - -#import - -void registerPlugins(NSObject* registry) { - [GeneratedPluginRegistrant registerWithRegistry:registry]; -} - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; - [GeofencingPlugin setPluginRegistrantCallback:registerPlugins]; - - // Override point for customization after application launch. - return [super application:application didFinishLaunchingWithOptions:launchOptions]; -} - -@end diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..70693e4a --- /dev/null +++ b/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png deleted file mode 100644 index 3d43d11e66f4de3da27ed045ca4fe38ad8b48094..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11112 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 P-1+_A+?hGkL;m(J7kc&K diff --git a/example/ios/Runner/GeneratedPluginRegistrant.h b/example/ios/Runner/GeneratedPluginRegistrant.h new file mode 100644 index 00000000..3b700eb4 --- /dev/null +++ b/example/ios/Runner/GeneratedPluginRegistrant.h @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +#ifndef GeneratedPluginRegistrant_h +#define GeneratedPluginRegistrant_h + +#import + +@interface GeneratedPluginRegistrant : NSObject ++ (void)registerWithRegistry:(NSObject*)registry; +@end + +#endif /* GeneratedPluginRegistrant_h */ diff --git a/example/ios/Runner/GeneratedPluginRegistrant.m b/example/ios/Runner/GeneratedPluginRegistrant.m new file mode 100644 index 00000000..2d243efe --- /dev/null +++ b/example/ios/Runner/GeneratedPluginRegistrant.m @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +#import "GeneratedPluginRegistrant.h" +#import + +@implementation GeneratedPluginRegistrant + ++ (void)registerWithRegistry:(NSObject*)registry { + [FlutterGeofencingPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterGeofencingPlugin"]]; +} + +@end diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 66743fce..c1845955 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -2,12 +2,10 @@ - NSLocationAlwaysAndWhenInUseUsageDescription - Required for Flutter Geofencing example events. - NSLocationWhenInUseUsageDescription - Required for Flutter Geofencing example events. + + CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -15,37 +13,42 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - geofencing_example + flutter_geofencing_example CFBundlePackageType APPL CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion - $(FLUTTER_BUILD_NUMBER) + $(CURRENT_PROJECT_VERSION) LSRequiresIPhoneOS + NSLocationAlwaysAndWhenInUseUsageDescription + YOUR DESCRIPTION HERE + NSLocationWhenInUseUsageDescription + YOUR DESCRIPTION HERE + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main - UIRequiredDeviceCapabilities - - location-services - gps - armv7 - - UIBackgroundModes - - location - UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIRequiredDeviceCapabilities + + location-services + gps + armv7 + + UIBackgroundModes + + location + UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait @@ -57,3 +60,4 @@ + diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..7335fdf9 --- /dev/null +++ b/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" \ No newline at end of file diff --git a/example/ios/Runner/main.m b/example/ios/Runner/main.m deleted file mode 100644 index dff6597e..00000000 --- a/example/ios/Runner/main.m +++ /dev/null @@ -1,9 +0,0 @@ -#import -#import -#import "AppDelegate.h" - -int main(int argc, char* argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b50b1014..97578a91 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,19 +1,13 @@ -name: geofencing_example -description: Demonstrates how to use the geofencing plugin. +name: flutter_geofencing_example +description: Demonstrates how to use the flutter_geofencing plugin. +publish_to: 'none' -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# Read more about versioning at semver.org. -version: 1.0.0+1 +environment: + sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter - flutter_geofencing: - path: ../ # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -23,8 +17,11 @@ dev_dependencies: flutter_test: sdk: flutter + flutter_geofencing: + path: ../ + # For information on the generic Dart part of this file, see the -# following page: https://www.dartlang.org/tools/pub/pubspec +# following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: @@ -40,10 +37,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -63,4 +60,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/flutter_geofencing.iml b/flutter_geofencing.iml index 429df7da..dc006829 100644 --- a/flutter_geofencing.iml +++ b/flutter_geofencing.iml @@ -10,9 +10,9 @@ + - diff --git a/lib/src/callback_dispatcher.dart b/lib/src/callback_dispatcher.dart index b1511531..dd52af77 100644 --- a/lib/src/callback_dispatcher.dart +++ b/lib/src/callback_dispatcher.dart @@ -31,5 +31,4 @@ void callbackDispatcher() { final GeofenceEvent event = intToGeofenceEvent(args[3]); callback(triggeringGeofences, triggeringLocation, event); }); - _backgroundChannel.invokeMethod('GeofencingService.initialized'); } diff --git a/pubspec.yaml b/pubspec.yaml index 39f873d1..b1ca7798 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,60 @@ name: flutter_geofencing -description: A geofencing plugin for Flutter applications - Works on both Android and iOS - supports Android X - based on Ben Konyi's Geofencing. -version: 0.1.2 -author: Karim Abdo & Bülent Hacioglu based on Ben Konyi -homepage: https://github.com/KarimAbdo/FlutterGeofencing +description: A new flutter plugin project. +version: 0.0.1 +author: +homepage: environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. flutter: + # This section identifies this Flutter project as a plugin project. + # The androidPackage and pluginClass identifiers should not ordinarily + # be modified. They are used by the tooling to maintain consistency when + # adding or updating assets for this project. plugin: - androidPackage: io.flutter.plugins.geofencing - pluginClass: GeofencingPlugin \ No newline at end of file + androidPackage: com.example.flutter_geofencing + pluginClass: FlutterGeofencingPlugin + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages From cf6809e333b3790b3204e13d42eb778b794c8b43 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 08:25:00 +0200 Subject: [PATCH 06/13] nuke static id --- ios/Classes/SwiftFlutterGeofencingPlugin.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/SwiftFlutterGeofencingPlugin.swift b/ios/Classes/SwiftFlutterGeofencingPlugin.swift index 41548496..337ab6a0 100644 --- a/ios/Classes/SwiftFlutterGeofencingPlugin.swift +++ b/ios/Classes/SwiftFlutterGeofencingPlugin.swift @@ -108,7 +108,7 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa func invoke(event: Int, region: CLRegion?) { let geofence = flGeofences.first { (g) in - if g.id == "de gamle" { + if g.id == region.identifier { return true } return false From 5bacc35fa5e24a6b078a40e85a902f6626d7ddf2 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 08:33:09 +0200 Subject: [PATCH 07/13] revert --- CHANGELOG.md | 2 +- LICENSE | 6 ++- README.md | 117 +++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 114 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d81..48ae0560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -## 0.0.1 +## 0.1.2 * TODO: Describe initial release. diff --git a/LICENSE b/LICENSE index ba75c69f..e662c786 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,5 @@ -TODO: Add your license here. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 3b49053b..a8d3de66 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,113 @@ -# flutter_geofencing +What is geofencing? +[here](https://developer.android.com/training/location/geofencing) -A new flutter plugin project. +This is based on Ben Konyi geofencing library, supporting AndroidX +Following is the documentation provided by him + +# Geofencing + +A sample geofencing plugin with background execution support for Flutter. ## Getting Started +This plugin works on both Android and iOS. Follow the instructions in the following sections for the +platforms which are to be targeted. + +### Android + +Add the following lines to your `AndroidManifest.xml` to register the background service for +geofencing: + +```xml + + +``` + +Also request the correct permissions for geofencing: + +```xml + +``` + +Finally, create either `Application.kt` or `Application.java` in the same directory as `MainActivity`. + +For `Application.kt`, use the following: + +```kotlin +class Application : FlutterApplication(), PluginRegistrantCallback { + override fun onCreate() { + super.onCreate(); + GeofencingService.setPluginRegistrant(this); + } + + override fun registerWith(registry: PluginRegistry) { + GeneratedPluginRegistrant.registerWith(registry); + } +} +``` + +For `Application.java`, use the following: + +```java +public class Application extends FlutterApplication implements PluginRegistrantCallback { + @Override + public void onCreate() { + super.onCreate(); + GeofencingService.setPluginRegistrant(this); + } + + @Override + public void registerWith(PluginRegistry registry) { + GeneratedPluginRegistrant.registerWith(registry); + } +} +``` + +Which must also be referenced in `AndroidManifest.xml`: + +```xml + + NSLocationAlwaysAndWhenInUseUsageDescription + YOUR DESCRIPTION HERE + NSLocationWhenInUseUsageDescription + YOUR DESCRIPTION HERE + ... +``` + +And request the correct permissions for geofencing: + +```xml + + ... + Main + UIRequiredDeviceCapabilities + + location-services + gps + armv7 + + UIBackgroundModes + + location + + ... + +``` + +### Need Help? -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. +For help getting started with Flutter, view our online +[documentation](https://flutter.io/). -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package). From 9182a039377a943cb4a0c8c4c45db4f66c317b0a Mon Sep 17 00:00:00 2001 From: theklausster Date: Tue, 22 Oct 2019 08:43:01 +0200 Subject: [PATCH 08/13] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b1ca7798..214ba7fb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_geofencing description: A new flutter plugin project. -version: 0.0.1 +version: 0.1.2 author: homepage: From 5d0e4f74408d728b119e295f76499cc0fb0ad266 Mon Sep 17 00:00:00 2001 From: "Kresten P. Vester" Date: Tue, 22 Oct 2019 09:09:47 +0200 Subject: [PATCH 09/13] Rename plugin class --- .../java/io/flutter/plugins/GeneratedPluginRegistrant.java | 4 ++-- .../{GeofencingPlugin.kt => FlutterGeofencingPlugin.kt} | 7 +++---- .../geofencing/GeofencingRebootBroadcastReceiver.kt | 2 +- .../io/flutter/plugins/geofencing/GeofencingService.kt | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) rename android/src/main/kotlin/io/flutter/plugins/geofencing/{GeofencingPlugin.kt => FlutterGeofencingPlugin.kt} (97%) diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index 07c1bd41..687042d6 100644 --- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -1,7 +1,7 @@ package io.flutter.plugins; import io.flutter.plugin.common.PluginRegistry; -import io.flutter.plugins.geofencing.GeofencingPlugin; +import io.flutter.plugins.geofencing.FlutterGeofencingPlugin; /** * Generated file. Do not edit. @@ -11,7 +11,7 @@ public static void registerWith(PluginRegistry registry) { if (alreadyRegisteredWith(registry)) { return; } - GeofencingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.geofencing.GeofencingPlugin")); + GeofencingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.geofencing.FlutterGeofencingPlugin")); } private static boolean alreadyRegisteredWith(PluginRegistry registry) { diff --git a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingPlugin.kt b/android/src/main/kotlin/io/flutter/plugins/geofencing/FlutterGeofencingPlugin.kt similarity index 97% rename from android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingPlugin.kt rename to android/src/main/kotlin/io/flutter/plugins/geofencing/FlutterGeofencingPlugin.kt index 66f7e704..b9d94fe8 100644 --- a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingPlugin.kt +++ b/android/src/main/kotlin/io/flutter/plugins/geofencing/FlutterGeofencingPlugin.kt @@ -22,16 +22,15 @@ import io.flutter.plugin.common.MethodChannel.Result import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.PluginRegistry.Registrar import org.json.JSONArray -import org.json.JSONObject -class GeofencingPlugin(context: Context, activity: Activity?) : MethodCallHandler { +class FlutterGeofencingPlugin(context: Context, activity: Activity?) : MethodCallHandler { private val mContext = context private val mActivity = activity private val mGeofencingClient = LocationServices.getGeofencingClient(mContext) companion object { @JvmStatic - private val TAG = "GeofencingPlugin" + private val TAG = "FlutterGeofencingPlugin" @JvmStatic val SHARED_PREFERENCES_KEY = "geofencing_plugin_cache" @JvmStatic @@ -49,7 +48,7 @@ class GeofencingPlugin(context: Context, activity: Activity?) : MethodCallHandle @JvmStatic fun registerWith(registrar: Registrar) { - val plugin = GeofencingPlugin(registrar.context(), registrar.activity()) + val plugin = FlutterGeofencingPlugin(registrar.context(), registrar.activity()) val channel = MethodChannel(registrar.messenger(), "plugins.flutter.io/geofencing_plugin") channel.setMethodCallHandler(plugin) } diff --git a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingRebootBroadcastReceiver.kt b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingRebootBroadcastReceiver.kt index 5b8cd0fa..e8b217c3 100644 --- a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingRebootBroadcastReceiver.kt +++ b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingRebootBroadcastReceiver.kt @@ -13,7 +13,7 @@ class GeofencingRebootBroadcastReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { Log.e("GEOFENCING REBOOT", "Reregistering geofences!") - GeofencingPlugin.reRegisterAfterReboot(context) + FlutterGeofencingPlugin.reRegisterAfterReboot(context) } } } \ No newline at end of file diff --git a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt index 150cdb85..d1117f51 100644 --- a/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt +++ b/android/src/main/kotlin/io/flutter/plugins/geofencing/GeofencingService.kt @@ -58,9 +58,9 @@ class GeofencingService : MethodCallHandler, JobIntentService() { mContext = context if (sBackgroundFlutterView == null) { val callbackHandle = context.getSharedPreferences( - GeofencingPlugin.SHARED_PREFERENCES_KEY, + FlutterGeofencingPlugin.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE) - .getLong(GeofencingPlugin.CALLBACK_DISPATCHER_HANDLE_KEY, 0) + .getLong(FlutterGeofencingPlugin.CALLBACK_DISPATCHER_HANDLE_KEY, 0) val callbackInfo = FlutterCallbackInformation.lookupCallbackInformation(callbackHandle) if (callbackInfo == null) { @@ -115,7 +115,7 @@ class GeofencingService : MethodCallHandler, JobIntentService() { } override fun onHandleWork(intent: Intent) { - val callbackHandle = intent.getLongExtra(GeofencingPlugin.CALLBACK_HANDLE_KEY, 0) + val callbackHandle = intent.getLongExtra(FlutterGeofencingPlugin.CALLBACK_HANDLE_KEY, 0) val geofencingEvent = GeofencingEvent.fromIntent(intent) if (geofencingEvent.hasError()) { Log.e(TAG, "Geofencing error: ${geofencingEvent.errorCode}") From 4370076568c5c569911ae8adf085db01f6f1a074 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 09:14:36 +0200 Subject: [PATCH 10/13] revoke --- lib/src/callback_dispatcher.dart | 1 + lib/src/geofencing.dart | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/callback_dispatcher.dart b/lib/src/callback_dispatcher.dart index dd52af77..b1511531 100644 --- a/lib/src/callback_dispatcher.dart +++ b/lib/src/callback_dispatcher.dart @@ -31,4 +31,5 @@ void callbackDispatcher() { final GeofenceEvent event = intToGeofenceEvent(args[3]); callback(triggeringGeofences, triggeringLocation, event); }); + _backgroundChannel.invokeMethod('GeofencingService.initialized'); } diff --git a/lib/src/geofencing.dart b/lib/src/geofencing.dart index 9f919400..40e7fd91 100644 --- a/lib/src/geofencing.dart +++ b/lib/src/geofencing.dart @@ -146,7 +146,6 @@ class GeofencingManager { PluginUtilities.getCallbackHandle(callback).toRawHandle() ]; args.addAll(region._toArgs()); - callbackDispatcher(); await _channel.invokeMethod('GeofencingPlugin.registerGeofence', args); } From 605b9aa050ee2f23facb670a4bf2e68a740f4817 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 09:43:02 +0200 Subject: [PATCH 11/13] implement missing method on method channel --- ios/Classes/SwiftFlutterGeofencingPlugin.swift | 12 ++++++++---- lib/src/geofencing.dart | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ios/Classes/SwiftFlutterGeofencingPlugin.swift b/ios/Classes/SwiftFlutterGeofencingPlugin.swift index 337ab6a0..22b9167a 100644 --- a/ios/Classes/SwiftFlutterGeofencingPlugin.swift +++ b/ios/Classes/SwiftFlutterGeofencingPlugin.swift @@ -25,7 +25,6 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa public static func register(with registrar: FlutterPluginRegistrar) { let instance = SwiftFlutterGeofencingPlugin() instance.setupCallHandler(registrar: registrar) - instance.callBackHandler = FlutterMethodChannel(name: "plugins.flutter.io/geofencing_plugin_background", binaryMessenger: registrar.messenger()) } func setupCallHandler(registrar: FlutterPluginRegistrar) { @@ -37,7 +36,6 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa self.locationManager.delegate = self self.locationManager.requestAlwaysAuthorization() let resultMap: [String: String] = [:] - result(resultMap) } else if call.method == "GeofencingPlugin.registerGeofence" { if let nsArray = call.arguments as? NSArray { @@ -48,7 +46,6 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa if let id = id, let lat = lat, let long = long { let flGeofence: FLGeofence = FLGeofence(callback: callbackHandle ?? 0, id: id, lat: lat.description, long: long.description) self.register(flGeofenceList: [flGeofence]) - self.invoke(event: 1, region: nil) } } let resultMap: [String: String] = [:] @@ -59,6 +56,13 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa result(resultMap) } } + + callBackHandler = FlutterMethodChannel(name: "plugins.flutter.io/geofencing_plugin_background", binaryMessenger: registrar.messenger()) + callBackHandler?.setMethodCallHandler { (call: FlutterMethodCall, result: FlutterResult) in + if call.method == "GeofencingService.initialized" { + result(nil) + } + } } func register(flGeofenceList: [FLGeofence]) -> Void { @@ -108,7 +112,7 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa func invoke(event: Int, region: CLRegion?) { let geofence = flGeofences.first { (g) in - if g.id == region.identifier { + if g.id == region?.identifier { return true } return false diff --git a/lib/src/geofencing.dart b/lib/src/geofencing.dart index 40e7fd91..9f919400 100644 --- a/lib/src/geofencing.dart +++ b/lib/src/geofencing.dart @@ -146,6 +146,7 @@ class GeofencingManager { PluginUtilities.getCallbackHandle(callback).toRawHandle() ]; args.addAll(region._toArgs()); + callbackDispatcher(); await _channel.invokeMethod('GeofencingPlugin.registerGeofence', args); } From b87f77acf67c9eda254ab4275b27eb67cb7b96e4 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Tue, 22 Oct 2019 10:07:45 +0200 Subject: [PATCH 12/13] revert --- pubspec.yaml | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 214ba7fb..5ce561fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,46 +15,7 @@ dev_dependencies: flutter_test: sdk: flutter -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. flutter: - # This section identifies this Flutter project as a plugin project. - # The androidPackage and pluginClass identifiers should not ordinarily - # be modified. They are used by the tooling to maintain consistency when - # adding or updating assets for this project. plugin: - androidPackage: com.example.flutter_geofencing + androidPackage: io.flutter.plugins.geofencing pluginClass: FlutterGeofencingPlugin - - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages From 0151638448d8d09a9301fd8bea54d8d516c3c5a2 Mon Sep 17 00:00:00 2001 From: Klaus Jakobsen Date: Wed, 23 Oct 2019 08:12:17 +0200 Subject: [PATCH 13/13] only send back the active ids onsite --- .../SwiftFlutterGeofencingPlugin.swift | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/ios/Classes/SwiftFlutterGeofencingPlugin.swift b/ios/Classes/SwiftFlutterGeofencingPlugin.swift index 22b9167a..664ff898 100644 --- a/ios/Classes/SwiftFlutterGeofencingPlugin.swift +++ b/ios/Classes/SwiftFlutterGeofencingPlugin.swift @@ -95,11 +95,11 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa } public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { - invoke(event: 1, region: region) + invoke(event: 1) } public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { - invoke(event: 2, region: region) + invoke(event: 2) } func removeRegionMonitering() { @@ -110,25 +110,16 @@ public class SwiftFlutterGeofencingPlugin: NSObject, FlutterPlugin, CLLocationMa } } - func invoke(event: Int, region: CLRegion?) { - let geofence = flGeofences.first { (g) in - if g.id == region?.identifier { - return true - } - return false - } + func invoke(event: Int) { + var args: [Any] = [] + var identifiers: [String] = [] + let regions = locationManager.monitoredRegions - if let geofence = geofence { - var args: [Any] = [] - args.append(geofence.callback) // callback Int - - args.append([geofence.id]) // triggeringGeofences List ids - - args.append([Double(geofence.lat) ?? 0.0, Double(geofence.long) ?? 0.0]) // locationList List long lat - - args.append(event) // _kEnterEvent = 1 / _kExitEvent = 2 - - callBackHandler?.invokeMethod("", arguments: args) + if !regions.isEmpty { + identifiers = regions.compactMap { $0.identifier } } + + args.append(identifiers) + callBackHandler?.invokeMethod("", arguments: args) } }