Fix android repeated request notification issues
This commit is contained in:
@@ -44,6 +44,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
|||||||
private var props: Props? = null
|
private var props: Props? = null
|
||||||
private lateinit var title: String
|
private lateinit var title: String
|
||||||
private lateinit var content: String
|
private lateinit var content: String
|
||||||
|
var isBlockNotification: Boolean = false
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
private val connection = object : ServiceConnection {
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
@@ -152,13 +153,14 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
|||||||
if (permission == PackageManager.PERMISSION_GRANTED) {
|
if (permission == PackageManager.PERMISSION_GRANTED) {
|
||||||
startForeground()
|
startForeground()
|
||||||
} else {
|
} else {
|
||||||
activity?.let {
|
if (isBlockNotification) return
|
||||||
ActivityCompat.requestPermissions(
|
if (activity == null) return
|
||||||
it,
|
ActivityCompat.requestPermissions(
|
||||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
activity!!,
|
||||||
NOTIFICATION_PERMISSION_REQUEST_CODE
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
)
|
NOTIFICATION_PERMISSION_REQUEST_CODE
|
||||||
}
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startForeground()
|
startForeground()
|
||||||
@@ -192,11 +194,14 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
|||||||
grantResults: IntArray
|
grantResults: IntArray
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
isBlockNotification = true
|
||||||
startForeground()
|
if (grantResults.isNotEmpty()) {
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
startForeground()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: fl_clash
|
name: fl_clash
|
||||||
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.8.31
|
version: 0.8.32
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.1.0 <4.0.0'
|
sdk: '>=3.1.0 <4.0.0'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user