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 67ac21a7
authored
2026-04-02 15:40:02 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
延迟初始化推送SDK
1 parent
5e48d4f1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
4 deletions
android/app/build.gradle.kts
android/app/src/main/AndroidManifest.xml
android/app/src/main/java/cn/banxe/bxe/MyApplication.java
android/app/src/main/java/cn/banxe/bxe/PrivacyActivity.java
lib/bloc/login_main_cubit.dart
android/app/build.gradle.kts
View file @
67ac21a
...
...
@@ -91,6 +91,9 @@ flutter {
}
dependencies {
// 添加 AppCompat 支持库(PrivacyActivity需要)
implementation("androidx.appcompat:appcompat:1.6.1")
// implementation("com.tencent.timpush:timpush:8.7.7201")
// implementation("com.tencent.liteav.tuikit:tuicore:8.7.7201")
// 版本号 "VERSION" 请前往 更新日志 中获取配置。
...
...
android/app/src/main/AndroidManifest.xml
View file @
67ac21a
...
...
@@ -21,7 +21,7 @@
<application
android:label=
"班小二"
android:name=
"
${applicationName}
"
android:name=
"
cn.banxe.bxe.MyApplication
"
android:icon=
"@mipmap/launcher_icon"
android:networkSecurityConfig=
"@xml/network_security_config"
>
...
...
android/app/src/main/java/cn/banxe/bxe/MyApplication.java
View file @
67ac21a
package
cn
.
banxe
.
bxe
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
com.tencent.chat.flutter.push.tencent_cloud_chat_push.application.TencentCloudChatPushApplication
;
public
class
MyApplication
extends
TencentCloudChatPushApplication
{
private
static
final
String
PREFS_NAME
=
"privacy_prefs"
;
private
static
final
String
KEY_AGREED
=
"privacy_agreed"
;
private
static
MyApplication
instance
;
@Override
public
void
onCreate
()
{
instance
=
this
;
// 只有在用户已同意隐私政策时才执行初始化
if
(
isPrivacyAgreed
())
{
super
.
onCreate
();
}
}
private
boolean
isPrivacyAgreed
()
{
SharedPreferences
prefs
=
getSharedPreferences
(
PREFS_NAME
,
Context
.
MODE_PRIVATE
);
return
prefs
.
getBoolean
(
KEY_AGREED
,
false
);
}
/**
* 用户同意隐私政策后调用,执行延迟初始化
*/
public
static
void
onPrivacyAgreed
()
{
if
(
instance
!=
null
&&
!
instance
.
isPrivacyAgreed
())
{
// 先保存同意状态
instance
.
savePrivacyAgreed
();
// 再执行初始化
instance
.
initSDKs
();
}
}
private
void
savePrivacyAgreed
()
{
SharedPreferences
prefs
=
getSharedPreferences
(
PREFS_NAME
,
Context
.
MODE_PRIVATE
);
prefs
.
edit
().
putBoolean
(
KEY_AGREED
,
true
).
apply
();
}
private
void
initSDKs
()
{
// 执行父类的初始化逻辑v
super
.
onCreate
();
}
}
\ No newline at end of file
android/app/src/main/java/cn/banxe/bxe/PrivacyActivity.java
View file @
67ac21a
...
...
@@ -155,9 +155,9 @@ public class PrivacyActivity extends Activity {
}
private
SpannableString
createClickableContent
()
{
String
text
=
"请您仔细阅读《用户协议》和《隐私政策》,
\n
充分理解协议内容。\n\n"
+
String
text
=
"请您仔细阅读《用户协议》和《隐私政策》,充分理解协议内容。\n\n"
+
"我们将严格遵守相关法律法规,保护您的个人信息安全。\n\n"
+
"点击
\"同意\"
即表示您已阅读并同意相关协议。"
;
"点击
“同意”
即表示您已阅读并同意相关协议。"
;
SpannableString
spannableString
=
new
SpannableString
(
text
);
...
...
@@ -202,7 +202,8 @@ public class PrivacyActivity extends Activity {
}
private
void
onAgreeClicked
()
{
savePrivacyAgreed
();
// 触发 Application 中的延迟初始化
MyApplication
.
onPrivacyAgreed
();
startMainActivity
();
}
...
...
lib/bloc/login_main_cubit.dart
View file @
67ac21a
import
'dart:io'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/locator.dart'
;
import
'package:appframe/config/routes.dart'
;
...
...
@@ -86,8 +88,10 @@ class LoginMainCubit extends Cubit<LoginMainState> {
_userAuthRepository
=
getIt
.
get
<
UserAuthRepository
>();
// 检查是否首次打开登录页面,显示个人信息收集提示
if
(
Platform
.
isIOS
)
{
_checkFirstTimePrivacy
();
}
}
// 检查是否首次打开,显示个人信息收集提示
void
_checkFirstTimePrivacy
()
async
{
...
...
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