增加离线推送代码
This commit is contained in:
parent
8945d7a34a
commit
117d5a8682
@ -38,6 +38,7 @@
|
|||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
78B9F60BE100248DF35D1C4A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
78B9F60BE100248DF35D1C4A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
|
8139D02F2A80CF4500E122A3 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
||||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@ -94,6 +95,7 @@
|
|||||||
97C146F01CF9000F007C117D /* Runner */ = {
|
97C146F01CF9000F007C117D /* Runner */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
8139D02F2A80CF4500E122A3 /* Runner.entitlements */,
|
||||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||||
@ -356,6 +358,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = C97QBVP4DP;
|
DEVELOPMENT_TEAM = C97QBVP4DP;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@ -503,6 +506,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = C97QBVP4DP;
|
DEVELOPMENT_TEAM = C97QBVP4DP;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@ -544,6 +548,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = C97QBVP4DP;
|
DEVELOPMENT_TEAM = C97QBVP4DP;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
|
|||||||
@ -8,6 +8,10 @@ import Flutter
|
|||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
GeneratedPluginRegistrant.register(with: self)
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
|
if #available(iOS 10.0, *) {
|
||||||
|
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
|
||||||
|
}
|
||||||
|
|
||||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
circle_app/ios/Runner/Runner.entitlements
Normal file
8
circle_app/ios/Runner/Runner.entitlements
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>aps-environment</key>
|
||||||
|
<string>development</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
87
circle_app/lib/common/values/pushconfig.dart
Normal file
87
circle_app/lib/common/values/pushconfig.dart
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
|
||||||
|
import 'package:tencent_chat_push_for_china/model/appInfo.dart';
|
||||||
|
import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart';
|
||||||
|
|
||||||
|
class PushConfig{
|
||||||
|
|
||||||
|
//These `Business ID` can be found in the offline push section for each manufacturers,
|
||||||
|
// on the main page of console from Tencent Cloud IM.
|
||||||
|
|
||||||
|
// Business ID for HUAWEI
|
||||||
|
static const HWPushBuzID = 0;
|
||||||
|
|
||||||
|
// Business ID for XiaoMi
|
||||||
|
static const XMPushBuzID = 0;
|
||||||
|
|
||||||
|
// APP Info of XiaoMi
|
||||||
|
static const String XMPushAPPID = "";
|
||||||
|
static const String XMPushAPPKEY = "";
|
||||||
|
|
||||||
|
// Business ID for Meizu
|
||||||
|
static const MZPushBuzID = 0;
|
||||||
|
|
||||||
|
// APP Info of Meizu
|
||||||
|
static const String MZPushAPPID = "";
|
||||||
|
static const String MZPushAPPKEY = "";
|
||||||
|
|
||||||
|
// Business ID for Vivo
|
||||||
|
static const VIVOPushBuzID = 0;
|
||||||
|
|
||||||
|
// Business ID for OPPO
|
||||||
|
static const OPPOPushBuzID = 0;
|
||||||
|
|
||||||
|
// APP Info of OPPO
|
||||||
|
static const String OPPOPushAPPKEY = "";
|
||||||
|
static const String OPPOPushAPPSECRET = "";
|
||||||
|
static const String OPPOPushAPPID = "";
|
||||||
|
static const String OPPOChannelID = "new_message";
|
||||||
|
|
||||||
|
|
||||||
|
// Business ID for Apple APNS 正式环境39381 测试环境39382
|
||||||
|
static const ApplePushBuzID = 39381;
|
||||||
|
|
||||||
|
|
||||||
|
static final PushAppInfo appInfo = PushAppInfo(
|
||||||
|
hw_buz_id: PushConfig.HWPushBuzID,
|
||||||
|
mi_app_id: PushConfig.XMPushAPPID,
|
||||||
|
mi_app_key: PushConfig.XMPushAPPKEY,
|
||||||
|
mi_buz_id: PushConfig.XMPushBuzID,
|
||||||
|
mz_app_id: PushConfig.MZPushAPPID,
|
||||||
|
mz_app_key: PushConfig.MZPushAPPKEY,
|
||||||
|
mz_buz_id: PushConfig.MZPushBuzID,
|
||||||
|
vivo_buz_id: PushConfig.VIVOPushBuzID,
|
||||||
|
oppo_app_key: PushConfig.OPPOPushAPPKEY,
|
||||||
|
oppo_app_secret: PushConfig.OPPOPushAPPSECRET,
|
||||||
|
oppo_buz_id: PushConfig.OPPOPushBuzID,
|
||||||
|
oppo_app_id: PushConfig.OPPOPushAPPID,
|
||||||
|
apple_buz_id: PushConfig.ApplePushBuzID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ChannelPush{
|
||||||
|
static final TimUiKitPushPlugin cPush = TimUiKitPushPlugin();
|
||||||
|
|
||||||
|
static init(PushClickAction pushClickAction) async {
|
||||||
|
// initialize the push plugin
|
||||||
|
cPush.init(
|
||||||
|
pushClickAction: pushClickAction,
|
||||||
|
appInfo: PushConfig.appInfo,
|
||||||
|
);
|
||||||
|
|
||||||
|
// create new notification channel
|
||||||
|
cPush.createNotificationChannel(
|
||||||
|
channelId: "new_message",
|
||||||
|
channelName: "chat_message",
|
||||||
|
channelDescription:
|
||||||
|
"The notification for chat message from Tencent Cloud IM"
|
||||||
|
);
|
||||||
|
|
||||||
|
// require the permission for notification
|
||||||
|
cPush.requireNotificationPermission();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String> getDeviceToken() async {
|
||||||
|
return cPush.getDevicePushToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:circle_app/app/splash/binding.dart';
|
import 'package:circle_app/app/splash/binding.dart';
|
||||||
|
import 'package:circle_app/common/values/pushconfig.dart';
|
||||||
import 'package:circle_app/network/api.dart';
|
import 'package:circle_app/network/api.dart';
|
||||||
import 'package:circle_app/network/dio_manager.dart';
|
import 'package:circle_app/network/dio_manager.dart';
|
||||||
import 'package:circle_app/router/app_pages.dart';
|
import 'package:circle_app/router/app_pages.dart';
|
||||||
@ -18,6 +19,9 @@ import 'package:get/get.dart';
|
|||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.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 'app/login/login/logic.dart';
|
import 'app/login/login/logic.dart';
|
||||||
import 'app/splash/view.dart';
|
import 'app/splash/view.dart';
|
||||||
|
|
||||||
@ -50,6 +54,17 @@ logoutIM() async {
|
|||||||
print(result.desc + '退出IM');
|
print(result.desc + '退出IM');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initPush() {
|
||||||
|
// final TimUiKitPushPlugin cPush = TimUiKitPushPlugin(
|
||||||
|
// isUseGoogleFCM: true, // 中国大陆版无此参数
|
||||||
|
// );
|
||||||
|
// cPush.init(
|
||||||
|
// pushClickAction: pushClickAction, // 单击通知后的事件回调,会在STEP6讲解
|
||||||
|
// appInfo: PushConfig.appInfo, // 传入STEP1做的appInfo
|
||||||
|
// );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//跳转发消息页面
|
//跳转发消息页面
|
||||||
pushChatPage(String userId, String imId, String userName) async {
|
pushChatPage(String userId, String imId, String userName) async {
|
||||||
var con = V2TimConversation(
|
var con = V2TimConversation(
|
||||||
@ -209,6 +224,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
initWxApi();
|
initWxApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadBuzIDAndToken();
|
||||||
loadBgImage();
|
loadBgImage();
|
||||||
super.initState();
|
super.initState();
|
||||||
// getLoginStyle();
|
// getLoginStyle();
|
||||||
@ -314,7 +331,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
splitScreenMode: true,
|
splitScreenMode: true,
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
return GetMaterialApp(
|
return GetMaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: '微乐园',
|
||||||
initialBinding: SplashBinding(),
|
initialBinding: SplashBinding(),
|
||||||
getPages: AppPages.routes,
|
getPages: AppPages.routes,
|
||||||
home: SplashPage(),
|
home: SplashPage(),
|
||||||
@ -323,4 +340,16 @@ class _MyAppState extends State<MyApp> {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取设备Token,获取成功后开启离线推送
|
||||||
|
void uploadBuzIDAndToken() async {
|
||||||
|
int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo);
|
||||||
|
String token = await ChannelPush.getDeviceToken();
|
||||||
|
if (token != "") {
|
||||||
|
coreInstance.setOfflinePushConfig(
|
||||||
|
token: token,
|
||||||
|
businessID: businessID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,9 +93,11 @@ dependencies:
|
|||||||
#event_bus:
|
#event_bus:
|
||||||
event_bus: ^2.0.0
|
event_bus: ^2.0.0
|
||||||
#安装apk
|
#安装apk
|
||||||
flutter_install_app: 1.3.0
|
# flutter_install_app: 1.3.0
|
||||||
#闪屏页
|
#闪屏页
|
||||||
flutter_native_splash: 2.2.16
|
flutter_native_splash: 2.2.16
|
||||||
|
#腾讯离线推送
|
||||||
|
tencent_chat_push_for_china: ^2.6.2+1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user