推送相关

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. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21 minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion flutter.targetSdkVersion
versionCode 13 versionCode 14
versionName "1.1.2" versionName "1.1.4"
manifestPlaceholders = [ manifestPlaceholders = [
vivo_APPID: "105669716", vivo_APPID: "105669716",
vivo_APPKEY:"84f750207787376b310ca5b0d5969122", vivo_APPKEY:"84f750207787376b310ca5b0d5969122",

View File

@ -12,7 +12,7 @@ buildscript {
} }
dependencies { 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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.6.0.300' 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 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import '../../common/values/pushconfig.dart'; import '../../common/values/pushconfig.dart';
import '../../main.dart';
import '../../util/PaymentUtils.dart'; import '../../util/PaymentUtils.dart';
import '../../util/SharedPreferencesHelper.dart'; import '../../util/SharedPreferencesHelper.dart';
import '../../util/device.dart'; import '../../util/device.dart';
@ -143,7 +144,7 @@ class _CustomDialogState extends State<YesAgreementDialog> {
var sp = await SharedPreferencesHelper.getInstance(); var sp = await SharedPreferencesHelper.getInstance();
sp.setBool(SharedPreferencesHelper.AGREEMENT, true); sp.setBool(SharedPreferencesHelper.AGREEMENT, true);
} catch (e) {} } catch (e) {}
await uploadBuzIDAndToken(); uploadBuzIDAndToken();
SmartDialog.dismiss(); SmartDialog.dismiss();
pushLoginPage(); pushLoginPage();
}, },
@ -195,39 +196,29 @@ class _CustomDialogState extends State<YesAgreementDialog> {
); );
} }
Future<bool> uploadBuzIDAndToken() async { // Future<bool> uploadBuzIDAndToken() async {
if (Platform.isAndroid) { // if (Platform.isAndroid) {
initWxApi(); // initWxApi();
} // }
AndroidDeviceInfo androidInfo; //
try { //
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); // final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance();
androidInfo = await deviceInfo.androidInfo; // await ChannelPush.init((msg) {});
} catch (e) { //
// // int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo);
return true; //
} // String token = await ChannelPush.getDeviceToken();
if (androidInfo.brand == 'Xiaomi'||androidInfo.brand == 'Redmi') { // ChannelPush.uploadToken();
//
}else{ // print("token=" + token);
final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance(); // if (token != "") {
await ChannelPush.init((msg) {}); // V2TimCallback res = await coreInstance.setOfflinePushConfig(
// token: token, businessID: businessID);
int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo); //
// print("token=" + res.code.toString());
String token = await ChannelPush.getDeviceToken(); // }
ChannelPush.uploadToken(); //
//
print("token=" + token); // return true;
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) { if (bean.code == 200) {
showOKToast('发送成功!'); showOKToast('发送成功!');
if (kDebugMode) { if (kDebugMode) {
print("验证码:${bean.data!.code}"); //print("验证码:${bean.data!.code}");
// codeEditingController.text = bean.data!.code.toString(); // codeEditingController.text = bean.data!.code.toString();
// update(); // update();
} }

View File

@ -281,7 +281,7 @@ class MyTabbedScreenState extends State<UserinfoPage>
shape: BoxShape.circle, shape: BoxShape.circle,
color: logic.isOnline color: logic.isOnline
? const Color(0xFF00FFF4) ? const Color(0xFF00FFF4)
: const Color(0xFF787575), : const Color(0x00000000),
), ),
), ),
logic.isBlack||logic.isDestroy||logic.isBlackBeen?Container(): Text( logic.isBlack||logic.isDestroy||logic.isBlackBeen?Container(): Text(
@ -290,7 +290,7 @@ class MyTabbedScreenState extends State<UserinfoPage>
fontSize: 12.sp, fontSize: 12.sp,
color: logic.isOnline color: logic.isOnline
? const Color(0xFF00FFF4) ? 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/model/appInfo.dart';
import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart'; import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart';
@ -12,6 +13,7 @@ class PushConfig{
// Business ID for XiaoMi // Business ID for XiaoMi
static const XMPushBuzID = 30672; static const XMPushBuzID = 30672;
static const String XMChannelID = "111363";
// APP Info of XiaoMi // APP Info of XiaoMi
static const String XMPushAPPID = "2882303761520264048"; static const String XMPushAPPID = "2882303761520264048";
@ -72,14 +74,32 @@ class ChannelPush{
appInfo: PushConfig.appInfo, appInfo: PushConfig.appInfo,
); );
print("token=初始化"+isInit.toString()); 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 // 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 // require the permission for notification
cPush.requireNotificationPermission(); cPush.requireNotificationPermission();