Charging resetting a singleton flag in the app extension?

My SingletonHelper class reads as:
Code Block
class SingletonHelper : NSObject{
private override init(){}
static let shared = SingletonHelper()
var firstRunFlag = true
}

And the messageReceived() in my SafariExtensionHandler class reads as:
Code Block
if SingletonHelper.shared.firstRunFlag == true{
NSWorkspace.shared.open(url)
SingletonHelper.shared.firstRunFlag = false
}


Ideally, the url would have opened up whenever the user opens Safari after right-clicking and quitting Safari. However, for some reason, it also opens up when I connect and disconnect my charging cable.
Why is connecting and disconnecting the cable resetting the firstRunFlag?
Once flag is false, you do not show where it is reset to true.

That is necessarily somewhere in your code.
@Claude31 That's the thing. I am not resetting it to true anywhere in my code. So the only way the value is true again is if the app restarts.
Charging resetting a singleton flag in the app extension?
 
 
Q