Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 8d06fd18
authored
2026-03-27 17:40:48 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整腾讯云IM SDK的初始化时机,以符合应用商店上架时的安全隐私检测。
1 parent
9215abd9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
lib/main.dart
lib/services/im_service.dart
lib/main.dart
View file @
8d06fd1
...
...
@@ -4,7 +4,6 @@ import 'dart:io';
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/env_config.dart'
;
import
'package:appframe/config/locator.dart'
;
import
'package:appframe/services/im_service.dart'
;
import
'package:appframe/ui/widgets/ios_edge_swipe_detector.dart'
;
import
'package:archive/archive.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -18,7 +17,6 @@ void main() async {
await
setupLocator
();
await
_initH5Version
();
await
_initImSdk
();
await
_initIOSGesture
();
runApp
(
const
App
());
...
...
@@ -58,12 +56,6 @@ Future<void> _initH5Version() async {
}
}
Future
<
void
>
_initImSdk
()
async
{
if
(
Constant
.
needIM
)
{
await
getIt
.
get
<
ImService
>().
initSdk
();
}
}
Future
<
void
>
_initIOSGesture
()
async
{
if
(
Platform
.
isIOS
)
{
// ios边缘滑动检测
...
...
lib/services/im_service.dart
View file @
8d06fd1
...
...
@@ -187,11 +187,19 @@ class ImService {
V2TimAdvancedMsgListener
get
msgListener
=>
_msgListener
;
///
// 添加初始化状态标记
bool
_isInitialized
=
false
;
bool
get
isInitialized
=>
_isInitialized
;
/// 初始化 IM SDK
///
Future
<
bool
>
initSdk
()
async
{
// 初始化SDK
// 防止重复初始化
if
(
_isInitialized
)
{
debugPrint
(
"IM SDK 已经初始化,跳过"
);
return
true
;
}
var
initSDKRes
=
await
TencentImSDKPlugin
.
v2TIMManager
.
initSDK
(
sdkAppID:
Constant
.
imSdkAppId
,
loglevel:
LogLevelEnum
.
V2TIM_LOG_ALL
,
...
...
@@ -199,6 +207,7 @@ class ImService {
);
if
(
initSDKRes
.
code
==
0
)
{
_isInitialized
=
true
;
// 标记已初始化
debugPrint
(
"IM SDK 初始化成功--------
${initSDKRes.data}
"
);
return
true
;
}
else
{
...
...
@@ -225,6 +234,9 @@ class ImService {
/// 登录 IM
///
Future
<
bool
>
login
(
String
userID
)
async
{
// 登录前先初始化SDK
await
initSdk
();
// 登录前先判断登录状态
var
loginStatus
=
await
TencentImSDKPlugin
.
v2TIMManager
.
getLoginStatus
();
if
(
loginStatus
.
code
==
0
)
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment