From 7cc1e40b365855dbf6d970061a12ead81ce69265 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 19 Mar 2024 18:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BA=E6=9E=81=E5=85=89?= =?UTF-8?q?=E6=8E=A8=E9=80=81=EF=BC=88=E5=AE=89=E5=8D=93=E5=89=8D=E5=8F=B0?= =?UTF-8?q?=E6=94=B6=E6=B6=88=E6=81=AF=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E3=80=81iOS=E5=89=8D=E5=90=8E=E5=8F=B0=E9=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=80=9A=E8=BF=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/android/app/build.gradle | 26 ++- .../android/app/src/main/AndroidManifest.xml | 85 ++++++---- .../kotlin/com/skychip/lock/MainActivity.kt | 21 +-- star_lock/android/build.gradle | 17 +- star_lock/ios/Podfile | 1 + .../ios/Runner/AliyunEmasServices-Info.plist | 20 +-- star_lock/ios/Runner/AppDelegate.h | 7 +- star_lock/ios/Runner/AppDelegate.m | 38 +++-- star_lock/ios/Runner/Info.plist | 160 +++++++++--------- star_lock/lib/app.dart | 52 +++--- star_lock/lib/tools/jpush_flutter.dart | 33 ++++ star_lock/lib/tools/xs_aliyunPush.dart | 2 + star_lock/pubspec.yaml | 1 + 13 files changed, 263 insertions(+), 200 deletions(-) create mode 100644 star_lock/lib/tools/jpush_flutter.dart diff --git a/star_lock/android/app/build.gradle b/star_lock/android/app/build.gradle index 93273b5f..4370f69c 100644 --- a/star_lock/android/app/build.gradle +++ b/star_lock/android/app/build.gradle @@ -23,7 +23,7 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' -apply plugin: 'com.aliyun.ams.emas-services' // 引用emas-services插件 +// apply plugin: 'com.aliyun.ams.emas-services' // 引用emas-services插件 apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" @@ -114,7 +114,7 @@ android { } defaultConfig { - + applicationId "com.skychip.lock" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion 25 @@ -129,6 +129,18 @@ android { //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so) abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64" } + + manifestPlaceholders = [ + JPUSH_PKGNAME : "com.skychip.lock", + //JPush 上注册的包名对应的 Appkey. + JPUSH_APPKEY : "7ff37d174c1a568a89e98dad", + //暂时填写默认值即可. + JPUSH_CHANNEL : "flutter_channel", + + //若不集成厂商通道,可直接跳过以下配置 + XIAOMI_APPID : "MI-2882303761520287291", + XIAOMI_APPKEY : "MI-5352028744291", + ] splits { abi { enable true @@ -140,6 +152,7 @@ android { } } } + buildTypes { release { // 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210) @@ -163,7 +176,10 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation('com.amap.api:location:5.6.0') implementation('com.amap.api:3dmap:8.1.0') - implementation 'com.aliyun.ams:alicloud-android-push:3.8.7' - //小米依赖 - implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.8.7' +// implementation 'com.aliyun.ams:alicloud-android-push:3.8.7' +// //小米依赖 +// implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.8.7' +// implementation 'cn.jiguang.sdk:jpush:4.0.9' +// implementation 'cn.jiguang.sdk:jcore:2.8.2' +// implementation 'cn.jiguang.sdk.plugin:xiaomi:4.0.9'//版本号和对应的JPush版本号相同 } diff --git a/star_lock/android/app/src/main/AndroidManifest.xml b/star_lock/android/app/src/main/AndroidManifest.xml index 25941a2b..112101d3 100644 --- a/star_lock/android/app/src/main/AndroidManifest.xml +++ b/star_lock/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + @@ -18,10 +18,6 @@ - - - - @@ -35,7 +31,10 @@ - + + @@ -49,36 +48,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -94,5 +64,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt b/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt index f3c4205b..33902047 100644 --- a/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt +++ b/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt @@ -16,9 +16,7 @@ import com.alibaba.sdk.android.push.register.MiPushRegister class MainActivity: FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initAliyunPushService() - - MiPushRegister.register(applicationContext, "2882303761520287291", "5352028744291"); +// initJPushService() GeneratedPluginRegistrant.registerWith(flutterEngine!!) MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result -> @@ -63,23 +61,6 @@ class MainActivity: FlutterActivity() { startActivity(Intent.createChooser(shareIntent, null)) } - private fun initAliyunPushService() { - PushServiceFactory.init(applicationContext) - val pushService = PushServiceFactory.getCloudPushService() - - val callback = object : CommonCallback, com.alibaba.sdk.android.push.CommonCallback { - override fun onSuccess(response: String?) { - Log.e("TAG","success $response") - } - - override fun onFailed(errorCode: String?, errorMessage: String?) { - Log.e("TAG","error $errorMessage") - } - } - - pushService.register(applicationContext,callback) - } - override fun configureFlutterEngine(flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { diff --git a/star_lock/android/build.gradle b/star_lock/android/build.gradle index bb5a7cca..67d2c573 100644 --- a/star_lock/android/build.gradle +++ b/star_lock/android/build.gradle @@ -4,16 +4,17 @@ buildscript { google() mavenCentral() mavenLocal() - maven { // 添加Maven仓库地址 - url 'https://maven.aliyun.com/nexus/content/repositories/releases/' - } +// maven { // 添加Maven仓库地址 +// url 'https://maven.aliyun.com/nexus/content/repositories/releases/' +// } } dependencies { classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // 添加emas-services插件 - classpath 'com.aliyun.ams:emas-services:1.0.4' +// classpath 'com.aliyun.ams:emas-services:1.0.4' + // classpath "cn.jiguang.sdk:jpush:4.0.9" } } @@ -21,11 +22,11 @@ buildscript { allprojects { repositories { google() -// mavenCentral() + mavenCentral() jcenter() - maven { // 添加Maven仓库地址 - url 'https://maven.aliyun.com/nexus/content/repositories/releases/' - } +// maven { // 添加Maven仓库地址 +// url 'https://maven.aliyun.com/nexus/content/repositories/releases/' +// } } } diff --git a/star_lock/ios/Podfile b/star_lock/ios/Podfile index fc1e6a3b..f60e3f48 100644 --- a/star_lock/ios/Podfile +++ b/star_lock/ios/Podfile @@ -36,6 +36,7 @@ end source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/aliyun/aliyun-specs.git' pod 'AlicloudPush', '~> 1.9.9' +pod 'JPush' post_install do |installer| installer.pods_project.targets.each do |target| diff --git a/star_lock/ios/Runner/AliyunEmasServices-Info.plist b/star_lock/ios/Runner/AliyunEmasServices-Info.plist index ea7823a7..4b1af180 100644 --- a/star_lock/ios/Runner/AliyunEmasServices-Info.plist +++ b/star_lock/ios/Runner/AliyunEmasServices-Info.plist @@ -5,23 +5,23 @@ config emas.appKey - 333904046 + 334068745 emas.appSecret - 3eead09a7fc7416cb4082319aa6f48c6 + bee9c200835e4951a85dc8709c319560 emas.bundleId cn.star-lock.starLock hotfix.idSecret - 333904046-2 + 334068745-2 hotfix.rsaSecret - MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCS0i6gEzm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.secretKey - f77f39c6f0e66d7c169aa7e8d87dfe13 + 6cd4984095d53f6f311424cc9299257b appmonitor.tlog.rsaSecret - MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB appmonitor.rsaSecret - MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB services @@ -65,7 +65,7 @@ status 1 version - 1.2.0 + 1.2.0-no-memory man_service @@ -79,7 +79,7 @@ status 1 version - 2.0.4 + 1.9.9.1-notnull diff --git a/star_lock/ios/Runner/AppDelegate.h b/star_lock/ios/Runner/AppDelegate.h index bb4ca173..582d3c3b 100644 --- a/star_lock/ios/Runner/AppDelegate.h +++ b/star_lock/ios/Runner/AppDelegate.h @@ -9,9 +9,14 @@ #import #import +#import "JPUSHService.h" +#import + +#import "JPUSHService.h" +#import -@interface AppDelegate : FlutterAppDelegate +@interface AppDelegate : FlutterAppDelegate @property (strong, nonatomic) UIWindow *window; diff --git a/star_lock/ios/Runner/AppDelegate.m b/star_lock/ios/Runner/AppDelegate.m index 56817721..557f519a 100644 --- a/star_lock/ios/Runner/AppDelegate.m +++ b/star_lock/ios/Runner/AppDelegate.m @@ -7,6 +7,7 @@ #import + @interface AppDelegate() @end @@ -18,6 +19,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +// //【注册通知】通知回调代理(可选) +// JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; +// entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings; +// [JPUSHService registerForRemoteNotificationConfig:entity delegate:self]; +// +// //【初始化sdk】 +// // notice: 2.1.5 版本的 SDK 新增的注册方法,改成可上报 IDFA,如果没有使用 IDFA 直接传 nil +// [JPUSHService setupWithOption:launchOptions appKey:@"7ff37d174c1a568a89e98dad" +// channel:@"flutter_channel" +// apsForProduction:NO +// advertisingIdentifier:nil]; + // [self initCloudPush]; // [CloudPushSDK sendNotificationAck:launchOptions]; XSFlutterManager *VC = [[XSFlutterManager alloc] init]; @@ -29,7 +42,7 @@ - (void)initCloudPush { // SDK初始化 - [CloudPushSDK asyncInit:@"333904046" appSecret:@"3eead09a7fc7416cb4082319aa6f48c6" callback:^(CloudPushCallbackResult *res) { + [CloudPushSDK asyncInit:@"334068745" appSecret:@"bee9c200835e4951a85dc8709c319560" callback:^(CloudPushCallbackResult *res) { if (res.success) { NSLog(@"Push SDK init success, deviceId: %@.", [CloudPushSDK getDeviceId]); } else { @@ -62,13 +75,16 @@ * 苹果推送注册成功回调,将苹果返回的deviceToken上传到CloudPush服务器 */ - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - [CloudPushSDK registerDevice:deviceToken withCallback:^(CloudPushCallbackResult *res) { - if (res.success) { - NSLog(@"Register deviceToken success."); - } else { - NSLog(@"Register deviceToken failed, error: %@", res.error); - } - }]; +// [CloudPushSDK registerDevice:deviceToken withCallback:^(CloudPushCallbackResult *res) { +// if (res.success) { +// NSLog(@"Register deviceToken success."); +// } else { +// NSLog(@"Register deviceToken failed, error: %@", res.error); +// } +// }]; + //sdk注册DeviceToken + [JPUSHService registerDeviceToken:deviceToken]; + } /* * 苹果推送注册失败回调 @@ -98,12 +114,6 @@ NSLog(@"Receive message title: %@, content: %@.", title, body); } -//- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { -// // 点击通知将App从关闭状态启动时,将通知打开回执上报 -// // [CloudPushSDK handleLaunching:launchOptions];(Deprecated from v1.8.1) -// [CloudPushSDK sendNotificationAck:launchOptions]; -// return YES; -//} /* * App处于启动状态时,通知打开回调 */ diff --git a/star_lock/ios/Runner/Info.plist b/star_lock/ios/Runner/Info.plist index 6484c6e2..33b2277b 100644 --- a/star_lock/ios/Runner/Info.plist +++ b/star_lock/ios/Runner/Info.plist @@ -1,82 +1,84 @@ - - CADisableMinimumFrameDurationOnPhone - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - $(BUNDLE_DISPLAY_NAME) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(BUNDLE_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSBluetoothAlwaysUsageDescription - The app uses bluetooth to find, connect and transfer data between different devices - NSBluetoothPeripheralUsageDescription - The app uses bluetooth to find, connect and transfer data between different devices - NSCameraUsageDescription - 照片 - NSContactsUsageDescription - Reason we need access to the contact list - NSLocationAlwaysAndWhenInUseUsageDescription - 应用在前台和后台的时候可以搜到更新的位置信息 - NSLocationAlwaysUsageDescription - 应用在后台的时候可以搜到更新的位置信息 - NSLocationWhenInUseUsageDescription - 应用在前台的时候可以搜到更新的位置信息 - NSMicrophoneUsageDescription - 应用请求麦克风用来通话 - NSPhotoLibraryUsageDescription - 用于相册 - UIApplicationSceneManifest - - UISceneConfigurations - - - UIApplicationSupportsIndirectInputEvents - - UIBackgroundModes - - remote-notification - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - - UIViewControllerBasedStatusBarAppearance - - io.flutter.embedded_views_preview - - - \ No newline at end of file + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + $(BUNDLE_DISPLAY_NAME) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(BUNDLE_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSBluetoothAlwaysUsageDescription + The app uses bluetooth to find, connect and transfer data between different devices + NSBluetoothPeripheralUsageDescription + The app uses bluetooth to find, connect and transfer data between different devices + NSCameraUsageDescription + 照片 + NSContactsUsageDescription + Reason we need access to the contact list + NSLocationAlwaysAndWhenInUseUsageDescription + 应用在前台和后台的时候可以搜到更新的位置信息 + NSLocationAlwaysUsageDescription + 应用在后台的时候可以搜到更新的位置信息 + NSLocationWhenInUseUsageDescription + 应用在前台的时候可以搜到更新的位置信息 + NSMicrophoneUsageDescription + 应用请求麦克风用来通话 + NSPhotoLibraryUsageDescription + 用于相册 + UIApplicationSceneManifest + + UISceneConfigurations + + + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + remote-notification + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortrait + + UIViewControllerBasedStatusBarAppearance + + NSUserTrackingUsageDescription + 需要访问您的隐私数据,以提供个性化的体验。 + io.flutter.embedded_views_preview + + + diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index ff5793ef..27fa403e 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -1,15 +1,16 @@ -import 'package:aliyun_push/aliyun_push.dart'; +// import 'package:aliyun_push/aliyun_push.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; -import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_aliyunPush.dart'; +// import 'package:star_lock/tools/storage.dart'; +// import 'package:star_lock/tools/xs_aliyunPush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -30,6 +31,8 @@ class MyApp extends StatefulWidget { // final RouteObserver routeObserver = RouteObserver(); class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { + final JPush jpush = JPush(); + @override Widget build(BuildContext context) { return ScreenUtilInit( @@ -101,7 +104,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); - initFlutterAliyunPush(); + initJPushService(); } @override @@ -109,6 +112,24 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { WidgetsBinding.instance.removeObserver(this); super.dispose(); } + + Future initJPushService() async { + jpush.setup( + appKey: "7ff37d174c1a568a89e98dad", + channel: "flutter_channel", + production: false, + debug: true, + ); + jpush.applyPushAuthority( + const NotificationSettingsIOS(sound: true, alert: true, badge: true)); + // jpush.setChannelAndSound( + // channel: "flutter_channel", channelID: "115700", sound: "default"); + + // Platform messages may fail, so we use a try/catch PlatformException. + jpush.getRegistrationID().then((rid) { + print("flutter get registration id : $rid"); + }); + } } void openBlueScan() { @@ -146,26 +167,3 @@ Future getMicrophonePermission() async { } return false; } - -//初始化阿里云推送 -Future initFlutterAliyunPush() async { - final data = await Storage.getString(saveUserLoginData); - if (data != null) { - final aliyunPush = AliyunPush(); - XSAliyunPushProvider().init(aliyunPush); - XSAliyunPushProvider().initAliyunPush(); - - if (Platform.isAndroid) { - XSAliyunPushProvider().initAliyunThirdPush(); - } - - //暂使用DeviceID推送 - aliyunPush.getDeviceId().then((deviceId) async { - print('得到的DeviceId$deviceId'); - if (deviceId.isNotEmpty) { - XSAliyunPushProvider() - .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); - } - }); - } -} diff --git a/star_lock/lib/tools/jpush_flutter.dart b/star_lock/lib/tools/jpush_flutter.dart new file mode 100644 index 00000000..fda3ee01 --- /dev/null +++ b/star_lock/lib/tools/jpush_flutter.dart @@ -0,0 +1,33 @@ +import 'package:jpush_flutter/jpush_flutter.dart'; + +class JPushProvider { + final JPush jpush = JPush(); + + Future initJPush() async { + jpush.setup( + appKey: "7ff37d174c1a568a89e98dad", + channel: "flutter_channel", + production: false, + debug: true, + ); + + jpush.applyPushAuthority(const NotificationSettingsIOS( + sound: true, + alert: true, + badge: true, + )); + + // // Add event handler + // jpush.addEventHandler( + // onReceiveNotification: (Map message) { + // print("Receive notification: $message"); + // }, + // onOpenNotification: (Map message) { + // print("Open notification: $message"); + // }, + // onReceiveMessage: (Map message) { + // print("Receive message: $message"); + // }, + // ); + } +} diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart index 600dfc94..4a922ebb 100644 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ b/star_lock/lib/tools/xs_aliyunPush.dart @@ -1,3 +1,4 @@ +/* import 'dart:io'; import 'package:aliyun_push/aliyun_push.dart'; @@ -133,3 +134,4 @@ class XSAliyunPushProvider { if (entity.errorCode!.codeIsSuccessful) {} } } +*/ \ No newline at end of file diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 54a0eb76..8a654d9e 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -114,6 +114,7 @@ dependencies: cached_network_image: ^3.2.0 webview_flutter: ^4.2.3 aliyun_push: ^0.1.6 + jpush_flutter: ^2.5.1 #视频播放器 video_player: ^2.7.1