| @@ -38,7 +38,7 @@ android { | |||
| defaultConfig { | |||
| // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | |||
| applicationId "com.example.farm_tpf" | |||
| applicationId "vn.azteam.tpfarm" | |||
| minSdkVersion 21 | |||
| targetSdkVersion 28 | |||
| versionCode flutterVersionCode.toInteger() | |||
| @@ -60,4 +60,6 @@ flutter { | |||
| dependencies { | |||
| implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |||
| implementation 'com.google.firebase:firebase-messaging:20.1.0' | |||
| } | |||
| apply plugin: 'com.google.gms.google-services' | |||
| @@ -0,0 +1,40 @@ | |||
| { | |||
| "project_info": { | |||
| "project_number": "618842128088", | |||
| "firebase_url": "https://tpfarm-825d1.firebaseio.com", | |||
| "project_id": "tpfarm-825d1", | |||
| "storage_bucket": "tpfarm-825d1.appspot.com" | |||
| }, | |||
| "client": [ | |||
| { | |||
| "client_info": { | |||
| "mobilesdk_app_id": "1:618842128088:android:5f81adc58e59c111dea1ad", | |||
| "android_client_info": { | |||
| "package_name": "vn.azteam.tpfarm" | |||
| } | |||
| }, | |||
| "oauth_client": [ | |||
| { | |||
| "client_id": "618842128088-etjunrg8qmvgcaena37qo2qn1i1latao.apps.googleusercontent.com", | |||
| "client_type": 3 | |||
| } | |||
| ], | |||
| "api_key": [ | |||
| { | |||
| "current_key": "AIzaSyBRkxNrNKNlzvXykRspeT-7Dcnw-o9ILGQ" | |||
| } | |||
| ], | |||
| "services": { | |||
| "appinvite_service": { | |||
| "other_platform_oauth_client": [ | |||
| { | |||
| "client_id": "618842128088-etjunrg8qmvgcaena37qo2qn1i1latao.apps.googleusercontent.com", | |||
| "client_type": 3 | |||
| } | |||
| ] | |||
| } | |||
| } | |||
| } | |||
| ], | |||
| "configuration_version": "1" | |||
| } | |||
| @@ -1,5 +1,5 @@ | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| package="com.example.farm_tpf"> | |||
| package="vn.azteam.tpfarm"> | |||
| <!-- Flutter needs it to communicate with the running application | |||
| to allow setting breakpoints, to provide hot reload, etc. | |||
| --> | |||
| @@ -1,5 +1,5 @@ | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| package="com.example.farm_tpf"> | |||
| package="vn.azteam.tpfarm"> | |||
| <!-- io.flutter.app.FlutterApplication is an android.app.Application that | |||
| calls FlutterMain.startInitialization(this); in its onCreate method. | |||
| In most cases you can leave this as-is, but you if you want to provide | |||
| @@ -8,7 +8,7 @@ | |||
| <uses-permission android:name="android.permission.INTERNET"/> | |||
| <uses-permission android:name="android.permission.CAMERA" /> | |||
| <application | |||
| android:name="io.flutter.app.FlutterApplication" | |||
| android:name=".Application" | |||
| android:label="farm_tpf" | |||
| android:icon="@mipmap/ic_launcher" | |||
| android:requestLegacyExternalStorage="true"> | |||
| @@ -40,6 +40,10 @@ | |||
| <action android:name="android.intent.action.MAIN"/> | |||
| <category android:name="android.intent.category.LAUNCHER"/> | |||
| </intent-filter> | |||
| <intent-filter> | |||
| <action android:name="FLUTTER_NOTIFICATION_CLICK" /> | |||
| <category android:name="android.intent.category.DEFAULT" /> | |||
| </intent-filter> | |||
| </activity> | |||
| <!-- Don't delete the meta-data below. | |||
| This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | |||
| @@ -0,0 +1,18 @@ | |||
| package vn.azteam.tpfarm | |||
| import io.flutter.app.FlutterApplication | |||
| import io.flutter.plugin.common.PluginRegistry | |||
| import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback | |||
| import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin | |||
| import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService | |||
| class Application : FlutterApplication(), PluginRegistrantCallback { | |||
| override fun onCreate() { | |||
| super.onCreate() | |||
| FlutterFirebaseMessagingService.setPluginRegistrant(this) | |||
| } | |||
| override fun registerWith(registry: PluginRegistry?) { | |||
| FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")) | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package vn.azteam.tpfarm | |||
| import io.flutter.plugin.common.PluginRegistry | |||
| import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin | |||
| object FirebaseCloudMessagingPluginRegistrant { | |||
| fun registerWith(registry: PluginRegistry) { | |||
| if (alreadyRegisteredWith(registry)) { | |||
| return | |||
| } | |||
| FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")) | |||
| } | |||
| private fun alreadyRegisteredWith(registry: PluginRegistry): Boolean { | |||
| val key = FirebaseCloudMessagingPluginRegistrant::class.java!!.getCanonicalName() | |||
| if (registry.hasPlugin(key)) { | |||
| return true | |||
| } | |||
| registry.registrarFor(key) | |||
| return false | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.example.farm_tpf | |||
| package vn.azteam.tpfarm | |||
| import io.flutter.embedding.android.FlutterActivity | |||
| @@ -1,5 +1,5 @@ | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| package="com.example.farm_tpf"> | |||
| package="vn.azteam.tpfarm"> | |||
| <!-- Flutter needs it to communicate with the running application | |||
| to allow setting breakpoints, to provide hot reload, etc. | |||
| --> | |||
| @@ -7,6 +7,7 @@ buildscript { | |||
| dependencies { | |||
| classpath 'com.android.tools.build:gradle:3.5.0' | |||
| classpath 'com.google.gms:google-services:4.3.3' | |||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |||
| } | |||
| } | |||
| @@ -3,16 +3,111 @@ PODS: | |||
| - Flutter | |||
| - MTBBarcodeScanner | |||
| - SwiftProtobuf | |||
| - Firebase/Analytics (6.30.0): | |||
| - Firebase/Core | |||
| - Firebase/Core (6.30.0): | |||
| - Firebase/CoreOnly | |||
| - FirebaseAnalytics (= 6.7.2) | |||
| - Firebase/CoreOnly (6.30.0): | |||
| - FirebaseCore (= 6.10.0) | |||
| - Firebase/Messaging (6.30.0): | |||
| - Firebase/CoreOnly | |||
| - FirebaseMessaging (~> 4.6.1) | |||
| - firebase_analytics (0.0.1): | |||
| - Firebase/Analytics (~> 6.0) | |||
| - Firebase/Core | |||
| - Flutter | |||
| - firebase_analytics_web (0.1.0): | |||
| - Flutter | |||
| - firebase_core (0.0.1): | |||
| - Firebase/Core | |||
| - Flutter | |||
| - firebase_core_web (0.1.0): | |||
| - Flutter | |||
| - firebase_messaging (0.0.1): | |||
| - Firebase/Core | |||
| - Firebase/Messaging | |||
| - Flutter | |||
| - FirebaseAnalytics (6.7.2): | |||
| - FirebaseCore (~> 6.8) | |||
| - FirebaseInstallations (~> 1.4) | |||
| - GoogleAppMeasurement (= 6.7.2) | |||
| - GoogleUtilities/AppDelegateSwizzler (~> 6.7) | |||
| - GoogleUtilities/MethodSwizzler (~> 6.7) | |||
| - GoogleUtilities/Network (~> 6.7) | |||
| - "GoogleUtilities/NSData+zlib (~> 6.7)" | |||
| - nanopb (~> 1.30905.0) | |||
| - FirebaseCore (6.10.0): | |||
| - FirebaseCoreDiagnostics (~> 1.3) | |||
| - GoogleUtilities/Environment (~> 6.7) | |||
| - GoogleUtilities/Logger (~> 6.7) | |||
| - FirebaseCoreDiagnostics (1.5.0): | |||
| - GoogleDataTransport (~> 7.0) | |||
| - GoogleUtilities/Environment (~> 6.7) | |||
| - GoogleUtilities/Logger (~> 6.7) | |||
| - nanopb (~> 1.30905.0) | |||
| - FirebaseInstallations (1.6.0): | |||
| - FirebaseCore (~> 6.10) | |||
| - GoogleUtilities/Environment (~> 6.7) | |||
| - GoogleUtilities/UserDefaults (~> 6.7) | |||
| - PromisesObjC (~> 1.2) | |||
| - FirebaseInstanceID (4.5.1): | |||
| - FirebaseCore (~> 6.8) | |||
| - FirebaseInstallations (~> 1.0) | |||
| - GoogleUtilities/Environment (~> 6.7) | |||
| - GoogleUtilities/UserDefaults (~> 6.7) | |||
| - FirebaseMessaging (4.6.1): | |||
| - FirebaseCore (~> 6.8) | |||
| - FirebaseInstanceID (~> 4.3) | |||
| - GoogleUtilities/AppDelegateSwizzler (~> 6.7) | |||
| - GoogleUtilities/Environment (~> 6.7) | |||
| - GoogleUtilities/Reachability (~> 6.7) | |||
| - GoogleUtilities/UserDefaults (~> 6.7) | |||
| - Protobuf (>= 3.9.2, ~> 3.9) | |||
| - Flutter (1.0.0) | |||
| - flutter_plugin_android_lifecycle (0.0.1): | |||
| - Flutter | |||
| - GoogleAppMeasurement (6.7.2): | |||
| - GoogleUtilities/AppDelegateSwizzler (~> 6.7) | |||
| - GoogleUtilities/MethodSwizzler (~> 6.7) | |||
| - GoogleUtilities/Network (~> 6.7) | |||
| - "GoogleUtilities/NSData+zlib (~> 6.7)" | |||
| - nanopb (~> 1.30905.0) | |||
| - GoogleDataTransport (7.2.0): | |||
| - nanopb (~> 1.30905.0) | |||
| - GoogleUtilities/AppDelegateSwizzler (6.7.2): | |||
| - GoogleUtilities/Environment | |||
| - GoogleUtilities/Logger | |||
| - GoogleUtilities/Network | |||
| - GoogleUtilities/Environment (6.7.2): | |||
| - PromisesObjC (~> 1.2) | |||
| - GoogleUtilities/Logger (6.7.2): | |||
| - GoogleUtilities/Environment | |||
| - GoogleUtilities/MethodSwizzler (6.7.2): | |||
| - GoogleUtilities/Logger | |||
| - GoogleUtilities/Network (6.7.2): | |||
| - GoogleUtilities/Logger | |||
| - "GoogleUtilities/NSData+zlib" | |||
| - GoogleUtilities/Reachability | |||
| - "GoogleUtilities/NSData+zlib (6.7.2)" | |||
| - GoogleUtilities/Reachability (6.7.2): | |||
| - GoogleUtilities/Logger | |||
| - GoogleUtilities/UserDefaults (6.7.2): | |||
| - GoogleUtilities/Logger | |||
| - image_picker (0.0.1): | |||
| - Flutter | |||
| - MTBBarcodeScanner (5.0.11) | |||
| - nanopb (1.30905.0): | |||
| - nanopb/decode (= 1.30905.0) | |||
| - nanopb/encode (= 1.30905.0) | |||
| - nanopb/decode (1.30905.0) | |||
| - nanopb/encode (1.30905.0) | |||
| - package_info (0.0.1): | |||
| - Flutter | |||
| - path_provider_linux (0.0.1): | |||
| - Flutter | |||
| - PromisesObjC (1.2.10) | |||
| - Protobuf (3.13.0) | |||
| - shared_preferences (0.0.1): | |||
| - Flutter | |||
| - shared_preferences_linux (0.0.1): | |||
| @@ -29,6 +124,11 @@ PODS: | |||
| DEPENDENCIES: | |||
| - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) | |||
| - firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`) | |||
| - firebase_analytics_web (from `.symlinks/plugins/firebase_analytics_web/ios`) | |||
| - firebase_core (from `.symlinks/plugins/firebase_core/ios`) | |||
| - firebase_core_web (from `.symlinks/plugins/firebase_core_web/ios`) | |||
| - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) | |||
| - Flutter (from `Flutter`) | |||
| - flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`) | |||
| - image_picker (from `.symlinks/plugins/image_picker/ios`) | |||
| @@ -43,12 +143,35 @@ DEPENDENCIES: | |||
| SPEC REPOS: | |||
| trunk: | |||
| - Firebase | |||
| - FirebaseAnalytics | |||
| - FirebaseCore | |||
| - FirebaseCoreDiagnostics | |||
| - FirebaseInstallations | |||
| - FirebaseInstanceID | |||
| - FirebaseMessaging | |||
| - GoogleAppMeasurement | |||
| - GoogleDataTransport | |||
| - GoogleUtilities | |||
| - MTBBarcodeScanner | |||
| - nanopb | |||
| - PromisesObjC | |||
| - Protobuf | |||
| - SwiftProtobuf | |||
| EXTERNAL SOURCES: | |||
| barcode_scan: | |||
| :path: ".symlinks/plugins/barcode_scan/ios" | |||
| firebase_analytics: | |||
| :path: ".symlinks/plugins/firebase_analytics/ios" | |||
| firebase_analytics_web: | |||
| :path: ".symlinks/plugins/firebase_analytics_web/ios" | |||
| firebase_core: | |||
| :path: ".symlinks/plugins/firebase_core/ios" | |||
| firebase_core_web: | |||
| :path: ".symlinks/plugins/firebase_core_web/ios" | |||
| firebase_messaging: | |||
| :path: ".symlinks/plugins/firebase_messaging/ios" | |||
| Flutter: | |||
| :path: Flutter | |||
| flutter_plugin_android_lifecycle: | |||
| @@ -74,12 +197,30 @@ EXTERNAL SOURCES: | |||
| SPEC CHECKSUMS: | |||
| barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 | |||
| Firebase: 210f41ca352067d83b1ba4fd2e7fb49a0c017397 | |||
| firebase_analytics: 9118044ffb98bee71d84733fc594f5134fe4bc1b | |||
| firebase_analytics_web: 7d539061ea4af07563a0e21044af89cab70efec0 | |||
| firebase_core: 335c02abd48672b7c83c683df833d0488a72e73e | |||
| firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 | |||
| firebase_messaging: 73b3e7dd7b3b6a7e4bdac10d5295211ca4f87f90 | |||
| FirebaseAnalytics: a299a86ef70fcc6aa011418bc65a7e101fb9636c | |||
| FirebaseCore: 9a41e2de78fef10f63cee30ab10e2945266bc1fc | |||
| FirebaseCoreDiagnostics: 7535fe695737f8c5b350584292a70b7f8ff0357b | |||
| FirebaseInstallations: 45f9d44d3a8d6f780fa337ee8987dad87210fcbc | |||
| FirebaseInstanceID: c4ad474b87787afd27d09541800620993b457d6f | |||
| FirebaseMessaging: 942cfe05b4f53c95ab8959395ca35c200398b2f0 | |||
| Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | |||
| flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35 | |||
| GoogleAppMeasurement: 3def7652b1f5b5a576178dc332e2a36a260fbef6 | |||
| GoogleDataTransport: 672fb0ce96fe7f7f31d43672fca62ad2c9c86f7b | |||
| GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3 | |||
| image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 | |||
| MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb | |||
| nanopb: c43f40fadfe79e8b8db116583945847910cbabc9 | |||
| package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 | |||
| path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 | |||
| PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151 | |||
| Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 | |||
| shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d | |||
| shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 | |||
| shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 | |||
| @@ -14,6 +14,7 @@ | |||
| 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 */; }; | |||
| FAD6CEB124FC9E250067930A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FAD6CEB024FC9E250067930A /* GoogleService-Info.plist */; }; | |||
| /* End PBXBuildFile section */ | |||
| /* Begin PBXCopyFilesBuildPhase section */ | |||
| @@ -47,6 +48,8 @@ | |||
| 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | |||
| 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | |||
| 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | |||
| FA128B3A24FC9B6100A49ACD /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; }; | |||
| FAD6CEB024FC9E250067930A /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; }; | |||
| /* End PBXFileReference section */ | |||
| /* Begin PBXFrameworksBuildPhase section */ | |||
| @@ -112,6 +115,8 @@ | |||
| 97C146F01CF9000F007C117D /* Runner */ = { | |||
| isa = PBXGroup; | |||
| children = ( | |||
| FAD6CEB024FC9E250067930A /* GoogleService-Info.plist */, | |||
| FA128B3A24FC9B6100A49ACD /* Runner.entitlements */, | |||
| 97C146FA1CF9000F007C117D /* Main.storyboard */, | |||
| 97C146FD1CF9000F007C117D /* Assets.xcassets */, | |||
| 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, | |||
| @@ -197,6 +202,7 @@ | |||
| files = ( | |||
| 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, | |||
| 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, | |||
| FAD6CEB124FC9E250067930A /* GoogleService-Info.plist in Resources */, | |||
| 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, | |||
| 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, | |||
| ); | |||
| @@ -363,6 +369,7 @@ | |||
| buildSettings = { | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 1; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| @@ -379,7 +386,7 @@ | |||
| "$(inherited)", | |||
| "$(PROJECT_DIR)/Flutter", | |||
| ); | |||
| PRODUCT_BUNDLE_IDENTIFIER = com.example.farmTpf; | |||
| PRODUCT_BUNDLE_IDENTIFIER = vn.azteam.tpfarm; | |||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||
| SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; | |||
| SWIFT_VERSION = 5.0; | |||
| @@ -502,6 +509,7 @@ | |||
| buildSettings = { | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 1; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| @@ -518,7 +526,7 @@ | |||
| "$(inherited)", | |||
| "$(PROJECT_DIR)/Flutter", | |||
| ); | |||
| PRODUCT_BUNDLE_IDENTIFIER = com.example.farmTpf; | |||
| PRODUCT_BUNDLE_IDENTIFIER = vn.azteam.tpfarm; | |||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||
| SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; | |||
| SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | |||
| @@ -533,6 +541,7 @@ | |||
| buildSettings = { | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 1; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| @@ -549,7 +558,7 @@ | |||
| "$(inherited)", | |||
| "$(PROJECT_DIR)/Flutter", | |||
| ); | |||
| PRODUCT_BUNDLE_IDENTIFIER = com.example.farmTpf; | |||
| PRODUCT_BUNDLE_IDENTIFIER = vn.azteam.tpfarm; | |||
| PRODUCT_NAME = "$(TARGET_NAME)"; | |||
| SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; | |||
| SWIFT_VERSION = 5.0; | |||
| @@ -8,6 +8,9 @@ import Flutter | |||
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |||
| ) -> Bool { | |||
| GeneratedPluginRegistrant.register(with: self) | |||
| if #available(iOS 10.0, *) { | |||
| UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate | |||
| } | |||
| return super.application(application, didFinishLaunchingWithOptions: launchOptions) | |||
| } | |||
| } | |||
| @@ -2,6 +2,8 @@ | |||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
| <plist version="1.0"> | |||
| <dict> | |||
| <key>FirebaseAppDelegateProxyEnabled</key> | |||
| <string>NO</string> | |||
| <key>CFBundleDevelopmentRegion</key> | |||
| <string>$(DEVELOPMENT_LANGUAGE)</string> | |||
| <key>CFBundleExecutable</key> | |||
| @@ -28,6 +30,11 @@ | |||
| <string>Use for record videos</string> | |||
| <key>NSPhotoLibraryUsageDescription</key> | |||
| <string>Get image for upload to server</string> | |||
| <key>UIBackgroundModes</key> | |||
| <array> | |||
| <string>fetch</string> | |||
| <string>remote-notification</string> | |||
| </array> | |||
| <key>UILaunchStoryboardName</key> | |||
| <string>LaunchScreen</string> | |||
| <key>UIMainStoryboardFile</key> | |||
| @@ -1,5 +1,8 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
| <plist version="1.0"> | |||
| <dict/> | |||
| <dict> | |||
| <key>aps-environment</key> | |||
| <string>development</string> | |||
| </dict> | |||
| </plist> | |||
| @@ -18,7 +18,7 @@ class HttpLogInterceptor extends InterceptorsWrapper { | |||
| var pref = LocalPref(); | |||
| @override | |||
| Future onRequest(RequestOptions options) async { | |||
| var token = await pref.getString(PrefKey.token_key); | |||
| var token = await pref.getString(DATA_CONST.TOKEN_KEY); | |||
| options.headers["Authorization"] = "Bearer $token"; | |||
| options.receiveTimeout = 20000; | |||
| log("onRequest: ${options.uri}\n" | |||
| @@ -34,4 +34,8 @@ abstract class RestClient { | |||
| @GET("/api/tb-supplies-by-type/{type}") | |||
| Future<List<Supply>> getSupplies(@Path() String type); | |||
| //Common | |||
| @PUT("/api/update-fcmToken") | |||
| Future<void> updateFcmToken(@Body() String token); | |||
| } | |||
| @@ -147,4 +147,21 @@ class _RestClient implements RestClient { | |||
| .toList(); | |||
| return value; | |||
| } | |||
| @override | |||
| updateFcmToken(token) async { | |||
| ArgumentError.checkNotNull(token, 'token'); | |||
| const _extra = <String, dynamic>{}; | |||
| final queryParameters = <String, dynamic>{}; | |||
| final _data = token; | |||
| await _dio.request<void>('/api/update-fcmToken', | |||
| queryParameters: queryParameters, | |||
| options: RequestOptions( | |||
| method: 'PUT', | |||
| headers: <String, dynamic>{}, | |||
| extra: _extra, | |||
| baseUrl: baseUrl), | |||
| data: _data); | |||
| return null; | |||
| } | |||
| } | |||
| @@ -18,8 +18,8 @@ class AuthenticationRepository { | |||
| Stream<AuthenticationStatus> get status async* { | |||
| try { | |||
| var token = await pref.getString(PrefKey.token_key); | |||
| var expiredTime = await pref.getString(PrefKey.expired_time); | |||
| var token = await pref.getString(DATA_CONST.TOKEN_KEY); | |||
| var expiredTime = await pref.getString(DATA_CONST.EXPIRED_TIME); | |||
| int currentTime = DateTime.now().millisecondsSinceEpoch; | |||
| bool isNotExpired = | |||
| (currentTime - int.tryParse(expiredTime)) < ConstCommon.kExpiredTime; | |||
| @@ -43,7 +43,7 @@ class AuthenticationRepository { | |||
| } | |||
| void logOut() { | |||
| pref.saveString(PrefKey.token_key, ""); | |||
| pref.saveString(DATA_CONST.TOKEN_KEY, ""); | |||
| _controller.add(AuthenticationStatus.unauthenticated); | |||
| } | |||
| @@ -25,4 +25,9 @@ class UserRepository { | |||
| final client = RestClient(dio); | |||
| return client.updateProfile(account); | |||
| } | |||
| Future<void> updateFcmToken(String token) { | |||
| final client = RestClient(dio); | |||
| return client.updateFcmToken(token); | |||
| } | |||
| } | |||
| @@ -5,3 +5,17 @@ import 'data/repository/authentication_repository.dart'; | |||
| void main() { | |||
| runApp(App(authenticationRepository: AuthenticationRepository())); | |||
| } | |||
| Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) { | |||
| if (message.containsKey('data')) { | |||
| // Handle data message | |||
| final dynamic data = message['data']; | |||
| } | |||
| if (message.containsKey('notification')) { | |||
| // Handle notification message | |||
| final dynamic notification = message['notification']; | |||
| } | |||
| // Or do other work. | |||
| } | |||
| @@ -1,16 +1,84 @@ | |||
| import 'dart:io'; | |||
| import 'package:dio/dio.dart'; | |||
| import 'package:farm_tpf/data/repository/user_repository.dart'; | |||
| import 'package:farm_tpf/main.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/nursery/sc_nursery.dart'; | |||
| import 'package:farm_tpf/presentation/screens/actions/plant/sc_plant.dart'; | |||
| import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | |||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | |||
| import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart'; | |||
| import 'package:farm_tpf/utils/const_common.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| import 'package:firebase_messaging/firebase_messaging.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| class HomePage extends StatelessWidget { | |||
| class HomePage extends StatefulWidget { | |||
| static Route route() { | |||
| return MaterialPageRoute<void>(builder: (_) => HomePage()); | |||
| } | |||
| @override | |||
| _HomePageState createState() => _HomePageState(); | |||
| } | |||
| class _HomePageState extends State<HomePage> { | |||
| UserRepository _userRepository = UserRepository(); | |||
| final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); | |||
| var pref = LocalPref(); | |||
| var token; | |||
| var client; | |||
| String pushkey = ""; | |||
| Future<Null> getSharedPrefs() async { | |||
| token = await pref.getString(DATA_CONST.TOKEN_KEY); | |||
| pushkey = await pref.getString(DATA_CONST.PUSH_KEY); | |||
| var options = BaseOptions(baseUrl: ConstCommon.baseUrl); | |||
| options.headers["Authorization"] = "Bearer $token"; | |||
| client = Dio(options); | |||
| if (Platform.isIOS) { | |||
| _firebaseMessaging | |||
| .requestNotificationPermissions(IosNotificationSettings()); | |||
| } | |||
| _firebaseMessaging.configure( | |||
| onMessage: (Map<String, dynamic> message) async { | |||
| print("onMessage: $message"); | |||
| }, | |||
| onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, | |||
| onLaunch: (Map<String, dynamic> message) async { | |||
| print("onLaunch: $message"); | |||
| }, | |||
| onResume: (Map<String, dynamic> message) async { | |||
| print("onResume: $message"); | |||
| }, | |||
| ); | |||
| _firebaseMessaging.requestNotificationPermissions( | |||
| const IosNotificationSettings( | |||
| sound: true, badge: true, alert: true, provisional: true)); | |||
| _firebaseMessaging.onIosSettingsRegistered | |||
| .listen((IosNotificationSettings settings) { | |||
| print("Settings registered: $settings"); | |||
| }); | |||
| if (pushkey?.isEmpty ?? true) { | |||
| _firebaseMessaging.getToken().then((String token) { | |||
| assert(token != null); | |||
| print("Push Messaging token: $token"); | |||
| _userRepository.updateFcmToken(token).then((value) { | |||
| print("send push key successful"); | |||
| pref.saveString(DATA_CONST.PUSH_KEY, token); | |||
| }); | |||
| // client.put(""); | |||
| }); | |||
| } else { | |||
| print("Don't need get push key"); | |||
| } | |||
| } | |||
| @override | |||
| void initState() { | |||
| super.initState(); | |||
| getSharedPrefs(); | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return Scaffold( | |||
| @@ -68,9 +68,9 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | |||
| state.password.value, | |||
| ); | |||
| var token = user.idToken; | |||
| pref.saveString(PrefKey.token_key, token); | |||
| pref.saveString(DATA_CONST.TOKEN_KEY, token); | |||
| int currentTime = DateTime.now().millisecondsSinceEpoch; | |||
| pref.saveString(PrefKey.expired_time, currentTime.toString()); | |||
| pref.saveString(DATA_CONST.EXPIRED_TIME, currentTime.toString()); | |||
| yield state.copyWith(status: FormzStatus.submissionSuccess); | |||
| } on Exception catch (_) { | |||
| @@ -14,14 +14,31 @@ class LocalPref extends Pref { | |||
| } | |||
| } | |||
| class MemoryPref extends Pref { | |||
| Map<String, Object> memoryMap = new Map<String, Object>(); | |||
| @override | |||
| Future<String> getString(String key) { | |||
| return Future.value(memoryMap[key]); | |||
| } | |||
| @override | |||
| Future<bool> saveString(String key, String value) async { | |||
| memoryMap[key] = value; | |||
| return Future.value(true); | |||
| } | |||
| } | |||
| abstract class Pref { | |||
| Future<bool> saveString(String key, String value); | |||
| Future<String> getString(String key); | |||
| } | |||
| class PrefKey { | |||
| static const String token_key = "token_key"; | |||
| static const String expired_time = "expired_time"; | |||
| static int kExpiredTime = 12 * 60 * 60 * 1000; //24h | |||
| class DATA_CONST { | |||
| static const String TOKEN_KEY = "TOKEN_KEY"; | |||
| static const String EXPIRED_TIME = "EXPIRED_TIME"; | |||
| static const String SHRIMP_LITER = "SHRIMP_LITER"; | |||
| static const String SHRIMP_POND_ID = "SHRIMP_POND_ID"; | |||
| static const String PUSH_KEY = "PUSH_KEY"; | |||
| } | |||
| @@ -113,6 +113,13 @@ packages: | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "7.1.0" | |||
| change_app_package_name: | |||
| dependency: "direct main" | |||
| description: | |||
| name: change_app_package_name | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "0.1.2" | |||
| charcode: | |||
| dependency: transitive | |||
| description: | |||
| @@ -204,6 +211,62 @@ packages: | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "5.2.1" | |||
| firebase: | |||
| dependency: transitive | |||
| description: | |||
| name: firebase | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "7.3.0" | |||
| firebase_analytics: | |||
| dependency: "direct main" | |||
| description: | |||
| name: firebase_analytics | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "5.0.16" | |||
| firebase_analytics_platform_interface: | |||
| dependency: transitive | |||
| description: | |||
| name: firebase_analytics_platform_interface | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "1.0.3" | |||
| firebase_analytics_web: | |||
| dependency: transitive | |||
| description: | |||
| name: firebase_analytics_web | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "0.1.1" | |||
| firebase_core: | |||
| dependency: "direct main" | |||
| description: | |||
| name: firebase_core | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "0.4.5" | |||
| firebase_core_platform_interface: | |||
| dependency: transitive | |||
| description: | |||
| name: firebase_core_platform_interface | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "1.0.4" | |||
| firebase_core_web: | |||
| dependency: transitive | |||
| description: | |||
| name: firebase_core_web | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "0.1.1+2" | |||
| firebase_messaging: | |||
| dependency: "direct main" | |||
| description: | |||
| name: firebase_messaging | |||
| url: "https://pub.dartlang.org" | |||
| source: hosted | |||
| version: "6.0.9" | |||
| fixnum: | |||
| dependency: transitive | |||
| description: | |||
| @@ -32,6 +32,11 @@ dependencies: | |||
| shimmer: ^1.1.1 | |||
| font_awesome_flutter: ^8.8.1 | |||
| package_info: ^0.4.3 | |||
| change_app_package_name: ^0.1.2 | |||
| firebase_analytics: any | |||
| firebase_messaging: 6.0.9 | |||
| firebase_core: ^0.4.0 | |||
| dev_dependencies: | |||
| flutter_test: | |||