推送相关

This commit is contained in:
yangyuhao 2023-09-09 15:33:30 +08:00
parent c53c61155a
commit c4780f7b23
6 changed files with 60 additions and 49 deletions

View File

@ -65,8 +65,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode 13
versionName "1.1.2"
versionCode 14
versionName "1.1.4"
manifestPlaceholders = [
vivo_APPID: "105669716",
vivo_APPKEY:"84f750207787376b310ca5b0d5969122",

View File

@ -12,7 +12,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}

View File

@ -13,6 +13,7 @@ import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import '../../common/values/pushconfig.dart';
import '../../main.dart';
import '../../util/PaymentUtils.dart';
import '../../util/SharedPreferencesHelper.dart';
import '../../util/device.dart';
@ -143,7 +144,7 @@ class _CustomDialogState extends State<YesAgreementDialog> {
var sp = await SharedPreferencesHelper.getInstance();
sp.setBool(SharedPreferencesHelper.AGREEMENT, true);
} catch (e) {}
await uploadBuzIDAndToken();
uploadBuzIDAndToken();
SmartDialog.dismiss();
pushLoginPage();
},
@ -195,39 +196,29 @@ class _CustomDialogState extends State<YesAgreementDialog> {
);
}
Future<bool> uploadBuzIDAndToken() async {
if (Platform.isAndroid) {
initWxApi();
}
AndroidDeviceInfo androidInfo;
try {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
androidInfo = await deviceInfo.androidInfo;
} catch (e) {
//
return true;
}
if (androidInfo.brand == 'Xiaomi'||androidInfo.brand == 'Redmi') {
}else{
final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance();
await ChannelPush.init((msg) {});
int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo);
String token = await ChannelPush.getDeviceToken();
ChannelPush.uploadToken();
print("token=" + token);
if (token != "") {
V2TimCallback res = await coreInstance.setOfflinePushConfig(
token: token, businessID: businessID);
print("token=" + res.code.toString());
}
}
return true;
}
// Future<bool> uploadBuzIDAndToken() async {
// if (Platform.isAndroid) {
// initWxApi();
// }
//
//
// final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance();
// await ChannelPush.init((msg) {});
//
// int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo);
//
// String token = await ChannelPush.getDeviceToken();
// ChannelPush.uploadToken();
//
// print("token=" + token);
// if (token != "") {
// V2TimCallback res = await coreInstance.setOfflinePushConfig(
// token: token, businessID: businessID);
//
// print("token=" + res.code.toString());
// }
//
//
// return true;
// }
}

View File

@ -67,7 +67,7 @@ class LoginLogic extends GetxController {
if (bean.code == 200) {
showOKToast('发送成功!');
if (kDebugMode) {
print("验证码:${bean.data!.code}");
//print("验证码:${bean.data!.code}");
// codeEditingController.text = bean.data!.code.toString();
// update();
}

View File

@ -281,7 +281,7 @@ class MyTabbedScreenState extends State<UserinfoPage>
shape: BoxShape.circle,
color: logic.isOnline
? const Color(0xFF00FFF4)
: const Color(0xFF787575),
: const Color(0x00000000),
),
),
logic.isBlack||logic.isDestroy||logic.isBlackBeen?Container(): Text(
@ -290,7 +290,7 @@ class MyTabbedScreenState extends State<UserinfoPage>
fontSize: 12.sp,
color: logic.isOnline
? const Color(0xFF00FFF4)
: const Color(0xFF787575),
: const Color(0x00000000),
),
),
],

View File

@ -1,4 +1,5 @@
import 'package:device_info/device_info.dart';
import 'package:tencent_chat_push_for_china/model/appInfo.dart';
import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart';
@ -12,6 +13,7 @@ class PushConfig{
// Business ID for XiaoMi
static const XMPushBuzID = 30672;
static const String XMChannelID = "111363";
// APP Info of XiaoMi
static const String XMPushAPPID = "2882303761520264048";
@ -72,14 +74,32 @@ class ChannelPush{
appInfo: PushConfig.appInfo,
);
print("token=初始化"+isInit.toString());
AndroidDeviceInfo androidInfo;
try {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
androidInfo = await deviceInfo.androidInfo;
} catch (e) {
//
return true;
}
if (androidInfo.brand == 'Xiaomi'||androidInfo.brand == 'Redmi') {
cPush.createNotificationChannel(
channelId: PushConfig.XMChannelID,
channelName: "消息推送",
channelDescription:
"The notification for chat message from Tencent Cloud IM"
);
}else{
cPush.createNotificationChannel(
channelId: PushConfig.OPPOChannelID,
channelName: "消息推送",
channelDescription:
"The notification for chat message from Tencent Cloud IM"
);
}
// create new notification channel
cPush.createNotificationChannel(
channelId: PushConfig.OPPOChannelID,
channelName: "消息推送",
channelDescription:
"The notification for chat message from Tencent Cloud IM"
);
// require the permission for notification
cPush.requireNotificationPermission();