Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios] not to send a event that will be dispatched when it came back to foreground from background. #37

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ios/Nativebrik/Nativebrik.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1540;
TargetAttributes = {
C136339C2AEB769800B9F437 = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -622,6 +622,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
Expand Down
7 changes: 6 additions & 1 deletion ios/Nativebrik/Nativebrik/component/trigger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TriggerViewController: UIViewController {
private var modalViewController: ModalComponentViewController? = nil
private var currentVC: UIViewController? = nil
private var didLoaded = false
private var ignoreFirstUserEventToForegroundEvent = true

required init?(coder: NSCoder) {
self.user = NativebrikUser()
Expand Down Expand Up @@ -49,11 +50,15 @@ class TriggerViewController: UIViewController {
// dispatch retention event
self.callWhenUserComeBack()

// dipatch retention event when user come back to foreground
// dipatch retention event when user come back to foreground from background
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
}

@objc func willEnterForeground() {
if self.ignoreFirstUserEventToForegroundEvent {
self.ignoreFirstUserEventToForegroundEvent = false
return
}
self.dispatch(event: NativebrikEvent(TriggerEventNameDefs.USER_ENTER_TO_FOREGROUND.rawValue))
self.callWhenUserComeBack()
}
Expand Down
Loading