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/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.+" } 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 d0ce7188..d1117f51 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 @@ -57,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) { @@ -114,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}") @@ -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) } } } } 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 3d43d11e..00000000 Binary files a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and /dev/null differ 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 a9be8323..97578a91 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,18 +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: ^0.0.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -22,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: @@ -39,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 @@ -62,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/geofencing.iml b/flutter_geofencing.iml similarity index 89% rename from geofencing.iml rename to flutter_geofencing.iml index 429df7da..dc006829 100644 --- a/geofencing.iml +++ b/flutter_geofencing.iml @@ -10,9 +10,9 @@ + - 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..664ff898 --- /dev/null +++ b/ios/Classes/SwiftFlutterGeofencingPlugin.swift @@ -0,0 +1,125 @@ +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) + } + + 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]) + } + } + let resultMap: [String: String] = [:] + result(resultMap) + } else if call.method == "GeofencingPlugin.removeGeofence" { + self.removeRegionMonitering() + let resultMap: [String: String] = [:] + 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 { + 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) + } + + public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { + invoke(event: 2) + } + + func removeRegionMonitering() { + let regions = locationManager.monitoredRegions + + for region in regions { + locationManager.stopMonitoring(for: region) + } + } + + func invoke(event: Int) { + var args: [Any] = [] + var identifiers: [String] = [] + let regions = locationManager.monitoredRegions + + if !regions.isEmpty { + identifiers = regions.compactMap { $0.identifier } + } + + args.append(identifiers) + 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); } diff --git a/pubspec.yaml b/pubspec.yaml index 39f873d1..5ce561fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,21 @@ 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. +description: A new flutter plugin project. version: 0.1.2 -author: Karim Abdo & Bülent Hacioglu based on Ben Konyi -homepage: https://github.com/KarimAbdo/FlutterGeofencing +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 + flutter: plugin: androidPackage: io.flutter.plugins.geofencing - pluginClass: GeofencingPlugin \ No newline at end of file + pluginClass: FlutterGeofencingPlugin