Browse Source

[fix]解决ios录音报错

Destiny 1 year ago
parent
commit
3f5237b57d
4 changed files with 61 additions and 19 deletions
  1. 12 0
      ios/Podfile
  2. 25 16
      ios/Podfile.lock
  3. 18 0
      ios/Runner.xcodeproj/project.pbxproj
  4. 6 3
      lib/utils/notification_util.dart

+ 12 - 0
ios/Podfile

@@ -40,5 +40,17 @@ end
 post_install do |installer|
   installer.pods_project.targets.each do |target|
     flutter_additional_ios_build_settings(target)
+
+target.build_configurations.each do |config|
+      # You can remove unused permissions here
+      # for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
+      # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
+      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
+        '$(inherited)',
+
+        ## dart: PermissionGroup.microphone
+        'PERMISSION_MICROPHONE=1',
+      ]
+     end
   end
 end

+ 25 - 16
ios/Podfile.lock

@@ -49,6 +49,10 @@ PODS:
     - Flutter
   - flutter_local_notifications (0.0.1):
     - Flutter
+  - flutter_sound (9.16.3):
+    - Flutter
+    - flutter_sound_core (= 9.16.3)
+  - flutter_sound_core (9.16.3)
   - flutter_umeng (0.0.1):
     - Flutter
   - gravity_engine (0.0.1):
@@ -58,21 +62,20 @@ PODS:
     - FlutterMacOS
   - just_audio (0.0.1):
     - Flutter
-  - MMKV (2.0.0):
-    - MMKVCore (~> 2.0.0)
-  - mmkv_ios (1.0.7):
+  - MMKV (1.3.9):
+    - MMKVCore (~> 1.3.9)
+  - mmkv_ios (1.0.8):
     - Flutter
-    - MMKV (< 2.1, >= 2.0.0)
-  - MMKVCore (2.0.0)
+    - MMKV (< 2.0, >= 1.3.9)
+  - MMKVCore (1.3.9)
   - package_info_plus (0.4.5):
     - Flutter
   - path_provider_foundation (0.0.1):
     - Flutter
     - FlutterMacOS
-  - photo_manager (2.0.0):
+  - permission_handler_apple (9.3.0):
     - Flutter
-    - FlutterMacOS
-  - record_darwin (1.0.0):
+  - photo_manager (2.0.0):
     - Flutter
     - FlutterMacOS
   - SDWebImage (5.19.7):
@@ -120,6 +123,7 @@ DEPENDENCIES:
   - Flutter (from `Flutter`)
   - flutter_foreground_task (from `.symlinks/plugins/flutter_foreground_task/ios`)
   - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
+  - flutter_sound (from `.symlinks/plugins/flutter_sound/ios`)
   - flutter_umeng (from `.symlinks/plugins/flutter_umeng/ios`)
   - gravity_engine (from `.symlinks/plugins/gravity_engine/ios`)
   - in_app_purchase_storekit (from `.symlinks/plugins/in_app_purchase_storekit/darwin`)
@@ -127,8 +131,8 @@ DEPENDENCIES:
   - mmkv_ios (from `.symlinks/plugins/mmkv_ios/ios`)
   - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
   - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
+  - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
   - photo_manager (from `.symlinks/plugins/photo_manager/ios`)
-  - record_darwin (from `.symlinks/plugins/record_darwin/ios`)
   - share_plus (from `.symlinks/plugins/share_plus/ios`)
   - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
   - shortcut (from `.symlinks/plugins/shortcut/ios`)
@@ -144,6 +148,7 @@ SPEC REPOS:
   trunk:
     - DKImagePickerController
     - DKPhotoGallery
+    - flutter_sound_core
     - MMKV
     - MMKVCore
     - SDWebImage
@@ -168,6 +173,8 @@ EXTERNAL SOURCES:
     :path: ".symlinks/plugins/flutter_foreground_task/ios"
   flutter_local_notifications:
     :path: ".symlinks/plugins/flutter_local_notifications/ios"
+  flutter_sound:
+    :path: ".symlinks/plugins/flutter_sound/ios"
   flutter_umeng:
     :path: ".symlinks/plugins/flutter_umeng/ios"
   gravity_engine:
@@ -182,10 +189,10 @@ EXTERNAL SOURCES:
     :path: ".symlinks/plugins/package_info_plus/ios"
   path_provider_foundation:
     :path: ".symlinks/plugins/path_provider_foundation/darwin"
+  permission_handler_apple:
+    :path: ".symlinks/plugins/permission_handler_apple/ios"
   photo_manager:
     :path: ".symlinks/plugins/photo_manager/ios"
-  record_darwin:
-    :path: ".symlinks/plugins/record_darwin/ios"
   share_plus:
     :path: ".symlinks/plugins/share_plus/ios"
   shared_preferences_foundation:
@@ -219,17 +226,19 @@ SPEC CHECKSUMS:
   Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
   flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817
   flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
+  flutter_sound: d9c7b35b2f19366439a74695d190d9a504a6b4fe
+  flutter_sound_core: 2c5d7e93183845b53a776d99c4d6ebc2933ec495
   flutter_umeng: 9005e3f776ff69868f0d75fbb2f11b33fbafc850
   gravity_engine: 750c5f2424a042f334f1154ece41d916eb148d6a
   in_app_purchase_storekit: 8c3b0b3eb1b0f04efbff401c3de6266d4258d433
   just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
-  MMKV: f7d1d5945c8765f97f39c3d121f353d46735d801
-  mmkv_ios: 9f1eb285b3188b2d9d02bb850201a521b4b75db8
-  MMKVCore: c04b296010fcb1d1638f2c69405096aac12f6390
+  MMKV: 817ba1eea17421547e01e087285606eb270a8dcb
+  mmkv_ios: 75b9f18f1baf8991985e095192a2b4e35f1e06ea
+  MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9
   package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
   path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
+  permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
   photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a
-  record_darwin: df0a677188e5fed18472550298e675f19ddaffbe
   SDWebImage: 8a6b7b160b4d710e2a22b6900e25301075c34cb3
   share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
   shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
@@ -243,6 +252,6 @@ SPEC CHECKSUMS:
   webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4
   wechat_kit: 2ae8a941c74332323910c34baac8a69549aa4a3f
 
-PODFILE CHECKSUM: a57f30d18f102dd3ce366b1d62a55ecbef2158e5
+PODFILE CHECKSUM: 7caf336f823524274eee12d7eeb37414067cfdfd
 
 COCOAPODS: 1.15.2

+ 18 - 0
ios/Runner.xcodeproj/project.pbxproj

@@ -202,6 +202,7 @@
 				9705A1C41CF9048500538489 /* Embed Frameworks */,
 				3B06AD1E1E4923F5004D2608 /* Thin Binary */,
 				E0233FF5C8A333174D045EEC /* [CP] Embed Pods Frameworks */,
+				6421544178EDEA67973376A3 /* [CP] Copy Pods Resources */,
 			);
 			buildRules = (
 			);
@@ -290,6 +291,23 @@
 			shellPath = /bin/sh;
 			shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
 		};
+		6421544178EDEA67973376A3 /* [CP] Copy Pods Resources */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputFileListPaths = (
+				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
+			);
+			name = "[CP] Copy Pods Resources";
+			outputFileListPaths = (
+				"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
+			showEnvVarsInLog = 0;
+		};
 		9740EEB61CF901F6004384FC /* Run Script */ = {
 			isa = PBXShellScriptBuildPhase;
 			alwaysOutOfDate = 1;

+ 6 - 3
lib/utils/notification_util.dart

@@ -1,6 +1,7 @@
 import 'package:custom_notification/custom_notification.dart';
 import 'package:electronic_assistant/module/talk/view.dart';
 import 'package:flutter_local_notifications/flutter_local_notifications.dart';
+import 'package:get/get_utils/src/platform/platform.dart';
 
 class NotificationUtil {
   NotificationUtil._();
@@ -16,9 +17,11 @@ class NotificationUtil {
   static void showRecordNotification(
       int notificationId, bool isRecording, double recordDuration,
       {required String channelId, required String channelName}) {
-    CustomNotification.showRecordNotification(
-        notificationId, isRecording, formatDuration(recordDuration),
-        channelId: channelId, channelName: channelName);
+    if (GetPlatform.isAndroid) {
+      CustomNotification.showRecordNotification(
+          notificationId, isRecording, formatDuration(recordDuration),
+          channelId: channelId, channelName: channelName);
+    }
   }
 
   static int _analyseNotificationId = 2000;