iOS Development
android – The way to disguise the app content material with splash display screen when app is in backgorund/inactive in flutter with bundle or technique channel

Hey guys i’m engaged on an app the place the consumer desires to point out the splash display screen when app is in background mode not a black display screen utilizing flag safe, anybody who might help me with it for android and ios
counsel a bundle which might help me perceive it or assist me with technique channel
Right here is the code for each
Android
class MainActivity: FlutterFragmentActivity() {
non-public val CHANNEL = "safety"
override enjoyable onCreate(savedInstanceState: Bundle?) {
if (intent.getIntExtra("org.chromium.chrome.additional.TASK_ID", -1) == this.taskId) {
this.end()
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
tremendous.onCreate(savedInstanceState)
}
override enjoyable configureFlutterEngine(flutterEngine: FlutterEngine) {
tremendous.configureFlutterEngine(flutterEngine)
setupMethodChannel(flutterEngine)
}
non-public enjoyable setupMethodChannel(flutterEngine: FlutterEngine) {
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { name, consequence ->
when (name.technique) {
"enableAppSecurity" -> {
enableAppSecurity()
consequence.success(null)
}
"disableAppSecurity" -> {
disableAppSecurity()
consequence.success(null)
}
else -> consequence.notImplemented()
}
}
}
override enjoyable onWindowFocusChanged(hasFocus: Boolean) {
tremendous.onWindowFocusChanged(hasFocus)
toggleAppSecurity(hasFocus)
}
override enjoyable onPause() {
tremendous.onPause()
enableAppSecurity()
}
override enjoyable onResume() {
tremendous.onResume()
disableAppSecurity()
}
non-public enjoyable toggleAppSecurity(hasFocus: Boolean) {
if (hasFocus) {
disableAppSecurity()
} else {
enableAppSecurity()
}
}
non-public enjoyable enableAppSecurity() {
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
}
non-public enjoyable disableAppSecurity() {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
IOS
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
non-public var flutterViewController: FlutterViewController!
non-public var securityChannel: FlutterMethodChannel!
non-public var blurEffectView: UIVisualEffectView?
non-public var isInBackground: Bool = false // Monitor whether or not app is in background
override func software(
_ software: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
setupFlutterCommunication()
// FirebaseApp.configure()
return tremendous.software(software, didFinishLaunchingWithOptions: launchOptions)
}
non-public func setupFlutterCommunication() {
flutterViewController = window?.rootViewController as? FlutterViewController
securityChannel = FlutterMethodChannel(
title: "safety",
binaryMessenger: flutterViewController.binaryMessenger
)
securityChannel.setMethodCallHandler(deal with)
}
override func applicationDidEnterBackground(_ software: UIApplication) {
isInBackground = true // App entered background
enableAppSecurity()
}
override func applicationDidBecomeActive(_ software: UIApplication) {
// Examine if the app was in background earlier than changing into lively
if isInBackground {
disableAppSecurity()
isInBackground = false
}
}
non-public func deal with(_ name: FlutterMethodCall, consequence: @escaping FlutterResult) {
swap name.technique {
case "enableAppSecurity":
consequence(nil)
case "disableAppSecurity":
consequence(nil)
default:
consequence(FlutterMethodNotImplemented)
}
}
non-public func enableAppSecurity() {
let blurEffect = UIBlurEffect(model: .mild)
blurEffectView = UIVisualEffectView(impact: blurEffect)
blurEffectView?.body = window!.body
window?.addSubview(blurEffectView!)
}
non-public func disableAppSecurity() {
blurEffectView?.removeFromSuperview()
}
}
Credit: www.ismmailgsm.com