更换为极光推送(安卓前台收消息测试通过、iOS前后台都测试通过)

This commit is contained in:
Daisy 2024-03-19 18:26:07 +08:00
parent 812e5d1ce4
commit 7cc1e40b36
13 changed files with 263 additions and 200 deletions

View File

@ -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版本号相同
}

View File

@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.star_lock">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.star_lock">
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />-->
@ -18,10 +18,6 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--允许获取wifi状态改变用于网络定位无gps情况下的定位若需网络定位功能则必选-->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<!--后台获取位置信息,若需后台定位则必选-->
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
<!--用于申请调用A-GPS模块,卫星定位加速-->
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />-->
<!--允许写设备缓存,用于问题排查-->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<!--允许写入扩展存储,用于写入缓存定位数据-->
@ -35,7 +31,10 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.REORDER_TASKS"/>
<application android:label="@string/app_name" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
<application android:label="@string/app_name" android:name="android.app.Application" android:icon="@mipmap/ic_launcher">
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<!-- 配置定位Service -->
<service android:name="com.amap.api.location.APSService"/>
<activity android:name="com.skychip.lock.MainActivity" android:exported="true" android:screenOrientation="portrait" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
@ -49,36 +48,7 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data android:name="flutterEmbedding" android:value="2"/>
<meta-data android:name="com.amap.api.v2.apikey" android:value="11d49b3f4fc09c04a02bbb7500925ba2"></meta-data>
<!-- 请填写你自己的- appKey -->
<meta-data android:name="com.alibaba.app.appkey" android:value="334068743"/>
<!-- 请填写你自己的appSecret -->
<meta-data android:name="com.alibaba.app.appsecret" android:value="64de537f14984159a66ada10e54c6b63"/>
<!-- 华为通道的参数appid -->
<meta-data android:name="com.huawei.hms.client.appid" android:value="appid=xxxxx"/>
<!-- vivo通道的参数api_key为appkey -->
<meta-data android:name="com.vivo.push.api_key" android:value=""/>
<meta-data android:name="com.vivo.push.app_id" android:value=""/>
<!-- honor通道的参数-->
<meta-data android:name="com.hihonor.push.app_id" android:value=""/>
<!-- oppo -->
<meta-data android:name="com.oppo.push.key" android:value=""/>
<meta-data android:name="com.oppo.push.secret" android:value=""/>
<!-- 小米-->
<meta-data android:name="com.xiaomi.push.id" android:value="id=2882303761520287291"/>
<meta-data android:name="com.xiaomi.push.key" android:value="id=5352028744291"/>
<!-- 魅族-->
<meta-data android:name="com.meizu.push.id" android:value=""/>
<meta-data android:name="com.meizu.push.key" android:value=""/>
<!-- fcm -->
<meta-data android:name="com.gcm.push.sendid" android:value="id=999999999999"/>
<meta-data android:name="com.gcm.push.applicationid" android:value=""/>
<meta-data android:name="com.gcm.push.projectid" android:value=""/>
<meta-data android:name="com.gcm.push.api.key" android:value=""/>
<!-- 消息接收监听器 (用户可自主扩展) -->
<receiver android:name="com.skychip.lock.MyMessageReceiver" android:exported="false">
<!-- 为保证receiver安全建议设置不可导出如需对其他应用开放可通过androidpermission进行限制 -->
<intent-filter>
@ -94,5 +64,48 @@
<action android:name="com.alibaba.sdk.android.push.RECEIVE"/>
</intent-filter>
</receiver>
<service
android:name="com.xiaomi.push.service.XMPushService"
android:process=":pushservice"
tools:replace="android:process">
</service>
<service
android:name="com.xiaomi.push.service.XMJobService"
android:process=":pushservice"
tools:replace="android:process">
</service>
<receiver
android:name="com.xiaomi.push.service.receivers.PingReceiver"
android:process=":pushservice"
tools:replace="android:process">
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<!-- <receiver android:name="com.skychip.lock.JPushEventReceiver"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />-->
<!-- <category android:name="${applicationId}" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<!-- &lt;!&ndash; Since JCore2.0.0 Required SDK核心功能&ndash;&gt;-->
<!-- &lt;!&ndash; 可配置android:process参数将Service放在其他进程中android:enabled属性不能是false &ndash;&gt;-->
<!-- &lt;!&ndash; 这个是自定义Service要继承极光JCommonService可以在更多手机平台上使得推送通道保持的更稳定 &ndash;&gt;-->
<!-- <service android:name=".JPushCustomService"-->
<!-- android:enabled="true"-->
<!-- android:exported="false"-->
<!-- android:process=":pushcore">-->
<!-- <intent-filter>-->
<!-- <action android:name="cn.jiguang.user.service.action" />-->
<!-- </intent-filter>-->
<!-- </service>-->
</application>
</manifest>

View File

@ -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 {

View File

@ -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/'
// }
}
}

View File

@ -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|

View File

@ -5,23 +5,23 @@
<key>config</key>
<dict>
<key>emas.appKey</key>
<string>333904046</string>
<string>334068745</string>
<key>emas.appSecret</key>
<string>3eead09a7fc7416cb4082319aa6f48c6</string>
<string>bee9c200835e4951a85dc8709c319560</string>
<key>emas.bundleId</key>
<string>cn.star-lock.starLock</string>
<key>hotfix.idSecret</key>
<string>333904046-2</string>
<string>334068745-2</string>
<key>hotfix.rsaSecret</key>
<string>MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCS0i6gEzmEoaXFe0gDcur1sdkE2ecWXRay3h+O11F0FmoNfQx+V4i+pt2se+KDAx/GQq8Axj4DnjzE4KT0TeVmrutI1FF4h2Tv5Ge9KT0yuCayiQPW5gkqTDxaehkRDyCzGkwaLkVslN2kFqammWsODTQw2a0/lziMrNpQU8bnjjYbKS1eIQUPM9s6smwN2A4RErAP7X1knsT1tCHoCgfgjZf1nddQSMw4vy9FBpKZDYD1gjdo5+U93VopVLpMqcbOVXbQeUwpArURNnY/dbSkrGsC2TXAfaYa+sVXPchy0pZ7C2wU2/6INkFBpw2QjFQ4uAcNXwoEn5x5iBw4VbnPAgMBAAECggEAfoowLT7kf+9iFIZgVrig0QlrZcb4aEnq2lafFFl3lnoLBX0VW37OGKNwwswzOX9jz1iBxEUYBb5H2ddT1Euev5Vaq/ZyEVOAJ1HQJzR3zlLw50c3y+uPUqlKCyDYod9L65FqrdXbd+4F6Pqsv0HTBtVSehfiPcBzuKrxrfHGqKKWx4C620SxPqtpNaYXaENyqfZ3qyKw+xtWGJtxjQ8DFkeWJ1C8O7ZxJ33SpwpEb9UIJpDtPcaKbwccLn/w5214kYAqE7m5aTmLUTFRYay2Hez1gPUKVirt/QDfEfHRv6xbv5jePl0snXWK0VwgoR3hLDuF9etM3UFLr40eQNICQQKBgQDCBjM7NvscgRCJ7E8vdcfxlebUhooZUewc9gBsTpPMcS8xZXP8desc1smZvokPtIKKwPdECw6rGf1a+sb6dnHMNjWBUbHTxWnYKqVlDDXJkgcSynK+74wRCfzmFamtQmJ1qVATHRVLoVSzmCwn9q+HsGWLAsMXDu5qbL6B91La2QKBgQDBuBHfPo4AwqefsPn5isw0bFYuc5rGSbfRTAlOC09BDJb2E9bz8QiC0A/Ar8i2fx9UbHKj96NYwMGwS49Bu/Behq5v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Dm07KkaRh0/Nofn3jSRs7zlFHSOUmhsAI0htEQx1x4f3MoBIuDtozv/eMT/XbGrNsP2i696TN39stnczrV3ZD7jzFvveEHRARaF4MvuLcRBrdQ=</string>
<key>httpdns.accountId</key>
<string>125761</string>
<string>100674</string>
<key>httpdns.secretKey</key>
<string>f77f39c6f0e66d7c169aa7e8d87dfe13</string>
<string>6cd4984095d53f6f311424cc9299257b</string>
<key>appmonitor.tlog.rsaSecret</key>
<string>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB</string>
<string>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB</string>
<key>appmonitor.rsaSecret</key>
<string>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB</string>
<string>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB</string>
</dict>
<key>services</key>
<dict>
@ -65,7 +65,7 @@
<key>status</key>
<integer>1</integer>
<key>version</key>
<string>1.2.0</string>
<string>1.2.0-no-memory</string>
</dict>
<key>man_service</key>
<dict>
@ -79,7 +79,7 @@
<key>status</key>
<integer>1</integer>
<key>version</key>
<string>2.0.4</string>
<string>1.9.9.1-notnull</string>
</dict>
</dict>
</dict>

View File

@ -9,9 +9,14 @@
#import <AudioToolbox/AudioToolbox.h>
#import <CloudPushSDK/CloudPushSDK.h>
#import "JPUSHService.h"
#import <UserNotifications/UserNotifications.h>
#import "JPUSHService.h"
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : FlutterAppDelegate <UIApplicationDelegate>
@interface AppDelegate : FlutterAppDelegate <UIApplicationDelegate, JPUSHRegisterDelegate>
@property (strong, nonatomic) UIWindow *window;

View File

@ -7,6 +7,7 @@
#import <UserNotifications/UserNotifications.h>
@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 @@
* deviceTokenCloudPush
*/
- (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);
// }
// }];
//sdkDeviceToken
[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
*/

View File

@ -1,82 +1,84 @@
<?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>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>$(BUNDLE_DISPLAY_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(BUNDLE_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSCameraUsageDescription</key>
<string>照片</string>
<key>NSContactsUsageDescription</key>
<string>Reason we need access to the contact list</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>应用在前台和后台的时候可以搜到更新的位置信息</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>应用在后台的时候可以搜到更新的位置信息</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>应用在前台的时候可以搜到更新的位置信息</string>
<key>NSMicrophoneUsageDescription</key>
<string>应用请求麦克风用来通话</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>用于相册</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UISceneConfigurations</key>
<dict/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>$(BUNDLE_DISPLAY_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(BUNDLE_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSCameraUsageDescription</key>
<string>照片</string>
<key>NSContactsUsageDescription</key>
<string>Reason we need access to the contact list</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>应用在前台和后台的时候可以搜到更新的位置信息</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>应用在后台的时候可以搜到更新的位置信息</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>应用在前台的时候可以搜到更新的位置信息</string>
<key>NSMicrophoneUsageDescription</key>
<string>应用请求麦克风用来通话</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>用于相册</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UISceneConfigurations</key>
<dict/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSUserTrackingUsageDescription</key>
<string>需要访问您的隐私数据,以提供个性化的体验。</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>

View File

@ -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<PageRoute> routeObserver = RouteObserver<PageRoute>();
class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
final JPush jpush = JPush();
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
@ -101,7 +104,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
initFlutterAliyunPush();
initJPushService();
}
@override
@ -109,6 +112,24 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
Future<void> 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<bool> getMicrophonePermission() async {
}
return false;
}
//
Future<void> 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);
}
});
}
}

View File

@ -0,0 +1,33 @@
import 'package:jpush_flutter/jpush_flutter.dart';
class JPushProvider {
final JPush jpush = JPush();
Future<void> 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<String, dynamic> message) {
// print("Receive notification: $message");
// },
// onOpenNotification: (Map<String, dynamic> message) {
// print("Open notification: $message");
// },
// onReceiveMessage: (Map<String, dynamic> message) {
// print("Receive message: $message");
// },
// );
}
}

View File

@ -1,3 +1,4 @@
/*
import 'dart:io';
import 'package:aliyun_push/aliyun_push.dart';
@ -133,3 +134,4 @@ class XSAliyunPushProvider {
if (entity.errorCode!.codeIsSuccessful) {}
}
}
*/

View File

@ -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