diff --git a/android/app/src/main/kotlin/com/follow/clash/plugins/ProxyPlugin.kt b/android/app/src/main/kotlin/com/follow/clash/plugins/ProxyPlugin.kt index 4e3444fe..482fc6a4 100644 --- a/android/app/src/main/kotlin/com/follow/clash/plugins/ProxyPlugin.kt +++ b/android/app/src/main/kotlin/com/follow/clash/plugins/ProxyPlugin.kt @@ -44,6 +44,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar private var props: Props? = null private lateinit var title: String private lateinit var content: String + var isBlockNotification: Boolean = false private val connection = object : ServiceConnection { override fun onServiceConnected(className: ComponentName, service: IBinder) { @@ -152,13 +153,14 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar if (permission == PackageManager.PERMISSION_GRANTED) { startForeground() } else { - activity?.let { - ActivityCompat.requestPermissions( - it, - arrayOf(Manifest.permission.POST_NOTIFICATIONS), - NOTIFICATION_PERMISSION_REQUEST_CODE - ) - } + if (isBlockNotification) return + if (activity == null) return + ActivityCompat.requestPermissions( + activity!!, + arrayOf(Manifest.permission.POST_NOTIFICATIONS), + NOTIFICATION_PERMISSION_REQUEST_CODE + ) + } } else { startForeground() @@ -192,11 +194,14 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar grantResults: IntArray ): Boolean { if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - startForeground() + isBlockNotification = true + if (grantResults.isNotEmpty()) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + startForeground() + } } } - return true; + return false; } diff --git a/pubspec.yaml b/pubspec.yaml index ea82b299..039d2220 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fl_clash description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. publish_to: 'none' -version: 0.8.31 +version: 0.8.32 environment: sdk: '>=3.1.0 <4.0.0'