-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
Pull request title looks good 👍! If this pull request gets merged, it will cause a new release of the software. Example: If this project's latest release version is All merged pull requests will eventually get deployed. But some types of pull requests will trigger a deployment (such as features and bug fixes) while some pull requests will wait to get deployed until a later time. This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...This project uses a special format for pull requests titles. Don't worry, it's easy! This pull request title should be in this format:
If your pull request introduces breaking changes to the code, use this format:
where
Examples:
Need more examples? Want to learn more about this format? Check out the official docs. Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests. |
Hey, there @Shahroz16 👋🤖. I'm a bot here to help you.
This pull request might still be allowed to be merged. However, you might want to consider make this pull request merge into a different branch other then This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...This project uses a special format for pull requests titles. Don't worry, it's easy! This pull request title should be in this format:
If your pull request introduces breaking changes to the code, use this format:
where
Examples:
Need more examples? Want to learn more about this format? Check out the official docs. Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests. |
Codecov Report
@@ Coverage Diff @@
## main #285 +/- ##
=========================================
+ Coverage 0 57.22% +57.22%
=========================================
Files 0 105 +105
Lines 0 1225 +1225
=========================================
+ Hits 0 701 +701
- Misses 0 524 +524
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that this comment I left is correct, then I approve of this PR.
That comment is important to make sure that FCM behavior is what I am expecting.
public static func initialize() { | ||
MessagingPush.shared.initializeModuleIfSdkInitialized() | ||
} | ||
|
||
@available(iOSApplicationExtension, unavailable) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
Adding labels to not merge this PR until all CI status checks on this PR runs successfully. This is especially important for the CocoaPods FCM app compiling to run successful for us to test the |
…roz-old-token-fix
Update: This PR is still blocked and should not be merged. Shahroz is changing the implementation as the previous solution did not work for FCM. |
…roz-old-token-fix
@levibostian would appreciate another review here. |
private let sdkInitializedUtil: SdkInitializedUtil | ||
|
||
// for writing tests | ||
// provide a nil implementation if you want `sdkInitializedUtil` logic to run and real instance of implementation to run in tests | ||
public init(implementation: ImplementationClass?, sdkInitializedUtil: SdkInitializedUtil) { | ||
public init(implementation: ImplementationClass?, globalDataStore: GlobalDataStore, sdkInitializedUtil: SdkInitializedUtil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does globalDataStore
need to be part of this init
function and class?
Since I don't see this class using this dependency, I would prefer we don't keep an instance of it in the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MessagingPush
is a singleton class. So to make it injectable, and testable I think this was the ideal way. But I might not be fully integrated with the iOS structure. So if there is any other way I can make it injectable in MessagingPush
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if you modify the constructor of MessagingPush
to something like this:
public class MessagingPush: ModuleTopLevelObject<MessagingPushInstance>, MessagingPushInstance {
@Atomic public private(set) static var shared = MessagingPush()
private let globalDataStore: GlobalDataStore
// testing constructor
override internal init(implementation: MessagingPushInstance?, globalDataStore: GlobalDataStore, sdkInitializedUtil: SdkInitializedUtil) {
super.init(implementation: implementation, sdkInitializedUtil: sdkInitializedUtil)
self.globalDataStore = globalDataStore
}
Then you wouldn't need to include globalDataStore
in this ModuleTopLevelObject
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that will work, a subclass constructor cannot have more parameters than its superclass constructor.
It will return Initializer does not override a designated initializer from its superclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying something out in Xcode right now. I'll update this comment or push a commit if I find something that will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As always, we can revert this commit if we don't like the solution.
Otherwise, let's resolve this conversation.
Changed title of PR because I believe this is a bug fix and not a feature. Of course, if anyone believes this is not a bug fix, change the title to suggest something different. |
…roz-old-token-fix
…roz-old-token-fix
…roz-old-token-fix
@levibostian could use a re-review here after the merge. I don't like the fact we are using |
### [2.5.1](2.5.0...2.5.1) (2023-05-12) ### Bug Fixes * sdk wrappers not having device token registered because of application lifecycle ([#285](#285)) ([da7fc51](da7fc51))
closes: https://github.com/customerio/issues/issues/9641
Complete each step to get your pull request merged in. Learn more about the workflow this project uses.