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

fix: sdk wrappers not having device token registered because of application lifecycle #285

Merged
merged 27 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8895cd7
test
Shahroz16 Apr 2, 2023
8fab6fa
auto generated files
Shahroz16 Apr 2, 2023
bf1a26a
sourcery
Shahroz16 Apr 2, 2023
1e770f2
remove unused import and added check for shared error
Shahroz16 Apr 12, 2023
662fc50
lint and generate
Shahroz16 Apr 12, 2023
c45b9ce
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 Apr 18, 2023
4807e85
refactor: make getting instances of classes before SDK initialization…
levibostian Apr 18, 2023
e5e2c8e
added comments and refactored name
Shahroz16 Apr 18, 2023
c6755d3
autogenerate
Shahroz16 Apr 18, 2023
b021b6d
added support to store device token and register on sdk init
Shahroz16 Apr 18, 2023
0256a46
autogenerate
Shahroz16 Apr 18, 2023
d0e37f5
autogenerate
Shahroz16 Apr 18, 2023
c0cce41
autogenerate
Shahroz16 Apr 18, 2023
36ee48e
autogenerate
Shahroz16 Apr 18, 2023
eb701ba
added global datastore support in modules
Shahroz16 Apr 18, 2023
edb46ab
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 Apr 18, 2023
3dbc9bd
updated method to avoid duplicate requests in native
Shahroz16 Apr 19, 2023
fa90fa0
throw error in case of cast failure
Shahroz16 Apr 19, 2023
d9807d0
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 Apr 19, 2023
01f66a4
remove global data store from ModuleTopLevelObject
levibostian Apr 20, 2023
02002b7
Merge branch 'main' into shahroz-old-token-fix
levibostian Apr 20, 2023
ef7510a
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 Apr 22, 2023
1a5bffb
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 May 3, 2023
d23bbf8
Merge branch 'main' of github.com:customerio/customerio-ios into shah…
Shahroz16 May 10, 2023
423328a
update globaldatastore
Shahroz16 May 10, 2023
fa1523e
fixed tests
Shahroz16 May 10, 2023
2cfd1ba
autogen
Shahroz16 May 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Common/Service/HttpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extension CIOHttpClient {
let requestHostname = url.host
let isRequestToCIOApi = cioApiHostname == requestHostname

return (isRequestToCIOApi) ? cioApiSession : publicSession
return isRequestToCIOApi ? cioApiSession : publicSession
}

static func getBasicAuthHeaderString(siteId: String, apiKey: String) -> String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/autogenerated/AutoLenses.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
38 changes: 1 addition & 37 deletions Sources/Common/autogenerated/AutoMockable.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down Expand Up @@ -2131,11 +2131,6 @@ public class QueueStorageMock: QueueStorage, Mock {
deleteReceivedArguments = nil
deleteReceivedInvocations = []

mockCalled = false // do last as resetting properties above can make this true
deleteTasksMemberOfGroupCallsCount = 0
deleteTasksMemberOfGroupReceivedArguments = nil
deleteTasksMemberOfGroupReceivedInvocations = []

mockCalled = false // do last as resetting properties above can make this true
deleteExpiredCallsCount = 0

Expand Down Expand Up @@ -2322,37 +2317,6 @@ public class QueueStorageMock: QueueStorage, Mock {
return deleteClosure.map { $0(storageId) } ?? deleteReturnValue
}

// MARK: - deleteTasksMemberOfGroup

/// Number of times the function was called.
public private(set) var deleteTasksMemberOfGroupCallsCount = 0
/// `true` if the function was ever called.
public var deleteTasksMemberOfGroupCalled: Bool {
deleteTasksMemberOfGroupCallsCount > 0
}

/// The arguments from the *last* time the function was called.
public private(set) var deleteTasksMemberOfGroupReceivedArguments: String?
/// Arguments from *all* of the times that the function was called.
public private(set) var deleteTasksMemberOfGroupReceivedInvocations: [String] = []
/// Value to return from the mocked function.
public var deleteTasksMemberOfGroupReturnValue: [QueueTaskMetadata]!
/**
Set closure to get called when function gets called. Great way to test logic or return a value for the function.
The closure has first priority to return a value for the mocked function. If the closure returns `nil`,
then the mock will attempt to return the value for `deleteTasksMemberOfGroupReturnValue`
*/
public var deleteTasksMemberOfGroupClosure: ((String) -> [QueueTaskMetadata])?

/// Mocked function for `deleteTasksMemberOfGroup(groupId: String)`. Your opportunity to return a mocked value and check result of mock in test code.
public func deleteTasksMemberOfGroup(groupId: String) -> [QueueTaskMetadata] {
mockCalled = true
deleteTasksMemberOfGroupCallsCount += 1
deleteTasksMemberOfGroupReceivedArguments = groupId
deleteTasksMemberOfGroupReceivedInvocations.append(groupId)
return deleteTasksMemberOfGroupClosure.map { $0(groupId) } ?? deleteTasksMemberOfGroupReturnValue
}

// MARK: - deleteExpired

/// Number of times the function was called.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
11 changes: 7 additions & 4 deletions Sources/MessagingPush/MessagingPush.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import CioTracking
import Common
import Foundation
#if canImport(UserNotifications) && canImport(UIKit)
#if canImport(UIKit)
import UIKit
import UserNotifications
#endif

/**
Expand All @@ -28,17 +27,21 @@ public class MessagingPush: ModuleTopLevelObject<MessagingPushInstance>, Messagi
Self.shared = MessagingPush()
}

// At this time, we do not require `MessagingPush.initialize()` to be called to make the SDK work. There is
// currently no module initialization to perform.
// initialize the module so that it can start automatically fetching device token
public static func initialize() {
MessagingPush.shared.initializeModuleIfSdkInitialized()
}

@available(iOSApplicationExtension, unavailable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a lot less work in the long-term of putting these functions as top-level in the stacktrace as possible. Example: It's better to put this annotation over initialize() function instead of over all the functions that initialize() calls.

With this in mind, I suggest we move this annotation over the static func initialize() function and see if it works. The Xcode compiler might complain and require us to put it over both functions. But, I think it's worth the time to see if moving it works.

override public func inititlizeModule(diGraph: DIGraph) {
let logger = diGraph.logger
logger.debug("Setting up MessagingPush module...")

logger.info("MessagingPush module setup with SDK")

#if canImport(UIKit)
UIApplication.shared.registerForRemoteNotifications()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we put a comment over this to specify why this we decided to add this function call.

#endif
}

override public func getImplementationInstance(diGraph: DIGraph) -> MessagingPushInstance {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
2 changes: 1 addition & 1 deletion Sources/Tracking/autogenerated/AutoLenses.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all

Expand Down