Skip to content

Commit

Permalink
Merge pull request #37 from plaidev/flutter
Browse files Browse the repository at this point in the history
[ios] not to send a event that will be dispatched when it came back to foreground from background.
  • Loading branch information
RyosukeCla authored Jun 4, 2024
2 parents 3b51466 + e613273 commit 618c861
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 618c861

Please sign in to comment.