Sfoglia il codice sorgente

[new]ios新增快捷跳转

Destiny 1 anno fa
parent
commit
24a6904c9c

+ 0 - 0
.vscode/launch.json


+ 24 - 5
ios/Podfile.lock

@@ -1,4 +1,6 @@
 PODS:
+  - app_links (0.0.2):
+    - Flutter
   - app_tracking_transparency (0.0.1):
     - Flutter
   - audio_session (0.0.1):
@@ -63,6 +65,9 @@ PODS:
   - path_provider_foundation (0.0.1):
     - Flutter
     - FlutterMacOS
+  - photo_manager (2.0.0):
+    - Flutter
+    - FlutterMacOS
   - record_darwin (1.0.0):
     - Flutter
     - FlutterMacOS
@@ -72,7 +77,9 @@ PODS:
   - shared_preferences_foundation (0.0.1):
     - Flutter
     - FlutterMacOS
-  - sqflite (0.0.3):
+  - shortcut (0.0.1):
+    - Flutter
+  - sqflite_darwin (0.0.4):
     - Flutter
     - FlutterMacOS
   - SwiftyGif (5.4.5)
@@ -96,6 +103,7 @@ PODS:
     - Flutter
 
 DEPENDENCIES:
+  - app_links (from `.symlinks/plugins/app_links/ios`)
   - app_tracking_transparency (from `.symlinks/plugins/app_tracking_transparency/ios`)
   - audio_session (from `.symlinks/plugins/audio_session/ios`)
   - connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
@@ -109,9 +117,11 @@ 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`)
+  - photo_manager (from `.symlinks/plugins/photo_manager/ios`)
   - record_darwin (from `.symlinks/plugins/record_darwin/ios`)
   - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
-  - sqflite (from `.symlinks/plugins/sqflite/darwin`)
+  - shortcut (from `.symlinks/plugins/shortcut/ios`)
+  - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
   - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
   - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
   - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`)
@@ -128,6 +138,8 @@ SPEC REPOS:
     - SwiftyGif
 
 EXTERNAL SOURCES:
+  app_links:
+    :path: ".symlinks/plugins/app_links/ios"
   app_tracking_transparency:
     :path: ".symlinks/plugins/app_tracking_transparency/ios"
   audio_session:
@@ -154,12 +166,16 @@ EXTERNAL SOURCES:
     :path: ".symlinks/plugins/package_info_plus/ios"
   path_provider_foundation:
     :path: ".symlinks/plugins/path_provider_foundation/darwin"
+  photo_manager:
+    :path: ".symlinks/plugins/photo_manager/ios"
   record_darwin:
     :path: ".symlinks/plugins/record_darwin/ios"
   shared_preferences_foundation:
     :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
-  sqflite:
-    :path: ".symlinks/plugins/sqflite/darwin"
+  shortcut:
+    :path: ".symlinks/plugins/shortcut/ios"
+  sqflite_darwin:
+    :path: ".symlinks/plugins/sqflite_darwin/darwin"
   url_launcher_ios:
     :path: ".symlinks/plugins/url_launcher_ios/ios"
   video_player_avfoundation:
@@ -172,6 +188,7 @@ EXTERNAL SOURCES:
     :path: ".symlinks/plugins/wechat_kit/ios"
 
 SPEC CHECKSUMS:
+  app_links: e7a6750a915a9e161c58d91bc610e8cd1d4d0ad0
   app_tracking_transparency: e169b653478da7bb15a6c61209015378ca73e375
   audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
   connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db
@@ -189,10 +206,12 @@ SPEC CHECKSUMS:
   MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9
   package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
   path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
+  photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a
   record_darwin: df0a677188e5fed18472550298e675f19ddaffbe
   SDWebImage: 981fd7e860af070920f249fd092420006014c3eb
   shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
-  sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
+  shortcut: 4fb7f85e55054fc349f3adc91dc852871ebc28b9
+  sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
   SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
   url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
   video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3

+ 1 - 1
ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

@@ -51,7 +51,7 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "Debug"
+      buildConfiguration = "Release"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"

+ 31 - 0
ios/Runner/Info.plist

@@ -22,10 +22,39 @@
 	<string>$(FLUTTER_BUILD_NAME)</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLName</key>
+			<string>weixin</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>wxff40112d61011372</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLName</key>
+			<string>xiaoting</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>xiaoting</string>
+			</array>
+		</dict>
+	</array>
 	<key>CFBundleVersion</key>
 	<string>$(FLUTTER_BUILD_NUMBER)</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
+	<key>LSApplicationQueriesSchemes</key>
+	<array>
+		<string>weixin</string>
+		<string>weixinULAPI</string>
+		<string>weixinURLParamsAPI</string>
+	</array>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>NSAppTransportSecurity</key>
@@ -39,6 +68,8 @@
 	<string>小听需要此权限用于选择文件上传录音功能</string>
 	<key>NSUserTrackingUsageDescription</key>
 	<string>小听需要使用您的广告标识符以显示个性化广告</string>
+	<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
+	<true/>
 	<key>UIApplicationSupportsIndirectInputEvents</key>
 	<true/>
 	<key>UIBackgroundModes</key>

+ 5 - 0
ios/Runner/Runner.entitlements

@@ -4,5 +4,10 @@
 <dict>
 	<key>aps-environment</key>
 	<string>development</string>
+	<key>com.apple.developer.associated-domains</key>
+	<array>
+		<string>applinks:xiaoting.atmob.com</string>
+		<string>applinks:flutter.dev</string>
+	</array>
 </dict>
 </plist>

+ 19 - 11
lib/module/splash/controller.dart

@@ -89,21 +89,29 @@ class SplashController extends BaseController {
 
   isAgreePrivacyNextStep() {
     //判断是否有额外操作执行
-    if (DesktopShortcutUtils.getRouteMap() != null) {
-      final routeMap = DesktopShortcutUtils.getRouteMap();
-      if (routeMap?[LaunchAction.key] == LaunchAction.recordAudioAction) {
-        _goMain(Duration.zero, arguments: routeMap);
-      } else {
-        _goMain(Duration(seconds: splashDelayedTime));
-      }
+    final routeMap = DesktopShortcutUtils.getRouteMap();
+    if (routeMap != null) {
+      _dealExistData(routeMap);
     } else {
-      _goMain(Duration(seconds: splashDelayedTime));
+      _normalGoMain();
     }
   }
 
-  void _goMain(Duration delayTime, {Map<String, dynamic>? arguments}) {
-    Timer(delayTime, () {
-      Get.offNamed(RoutePath.mainTab, arguments: arguments);
+  _dealExistData(Map<String, dynamic> routeMap) {
+    if (routeMap[LaunchAction.key] == LaunchAction.recordAudioAction) {
+      //录音
+      Get.offNamed(RoutePath.mainTab);
+      Get.toNamed(RoutePath.record);
+      DesktopShortcutUtils.clearRouteMap();
+    } else {
+      _normalGoMain();
+    }
+  }
+
+  void _normalGoMain() {
+    // registerIosDeeplink();
+    Timer(Duration(seconds: splashDelayedTime), () {
+      Get.offNamed(RoutePath.mainTab);
     });
   }
 }

+ 32 - 1
lib/utils/desktop_shortcut_utils.dart

@@ -1,10 +1,16 @@
+import 'dart:async';
 import 'dart:io';
 
+import 'package:app_links/app_links.dart';
 import 'package:electronic_assistant/base/base_controller.dart';
+import 'package:electronic_assistant/main.dart';
 import 'package:electronic_assistant/router/app_pages.dart';
 import 'package:electronic_assistant/utils/mmkv_util.dart';
+import 'package:electronic_assistant/utils/toast_util.dart';
+import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:get/get_core/src/get_main.dart';
+import 'package:url_launcher/url_launcher.dart';
 import '../dialog/desktop_shortcut_dialog.dart';
 import 'android_shortcut.dart';
 
@@ -18,14 +24,30 @@ class DesktopShortcutUtils {
 
   static Map<String, dynamic>? intentMap;
 
+  static StreamSubscription<Uri>? linkSubscription;
+
+  static AppLinks appLinks = AppLinks();
+
   static Future<void> registerDesktopShortcut() async {
     if (Platform.isAndroid) {
       androidShortCut.register();
     } else if (Platform.isIOS) {
       //TODO IOS
+      registerIosDeeplink();
     }
   }
 
+  static Future<void> registerIosDeeplink() async {
+    // Handle links
+    linkSubscription = appLinks.uriLinkStream.listen((uri) {
+      debugPrint('onAppLink: $uri');
+      if (uri.scheme == "xiaoting") {
+        DesktopShortcutUtils.setLaunchAction(LaunchAction.recordAudioAction);
+        DesktopShortcutUtils.setRouteAction(LaunchAction.recordAudioAction);
+      }
+    });
+  }
+
   static void isShowTipsDialog(void Function() nextCallback) {
     if (!_isShow()) {
       nextCallback();
@@ -39,7 +61,8 @@ class DesktopShortcutUtils {
           nextCallback();
         });
       } else if (Platform.isIOS) {
-        //TODO IOS
+        _launchUrl();
+        nextCallback();
       }
     }, onCancel: () {
       nextCallback();
@@ -47,6 +70,13 @@ class DesktopShortcutUtils {
     _setShowOnce();
   }
 
+  static Future<void> _launchUrl() async {
+    final Uri url = Uri.parse('https://xiaoting.atmob.com/record');
+    if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
+      throw Exception('Could not launch');
+    }
+  }
+
   static bool _isShow() {
     return KVUtil.getInt(_showMaxTimeTag, 0) < _showMaxFrequency;
   }
@@ -66,6 +96,7 @@ class DesktopShortcutUtils {
           onDismiss: () {});
     } else if (Platform.isIOS) {
       //TODO IOS
+      _launchUrl();
     }
   }
 

File diff suppressed because it is too large
+ 249 - 209
pubspec.lock