Skip to content

Conversation

@nickolas-dimitrakas
Copy link
Contributor

@nickolas-dimitrakas nickolas-dimitrakas commented Oct 27, 2025

Background

  • The static methods in MPNotificationController and MPStateMachine made it difficult to mock or test functionality related to push notification handling. This also created tight coupling between components and limited flexibility when integrating with other parts of the SDK.

What Has Changed

  • Replaced static methods in MPNotificationController and MPStateMachine with instance methods.
  • Updated references throughout the codebase to use the appropriate instance accessors instead of static calls.

Screenshots/Video

  • N/A

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • I have chosen the base branch as the branch that I will add unit tests on.

Reference Issue (For employees only. Ignore if you are an outside contributor)

@nickolas-dimitrakas nickolas-dimitrakas requested a review from a team as a code owner October 27, 2025 14:10
@nickolas-dimitrakas nickolas-dimitrakas changed the base branch from main to test/add-test-coverage-for-application-notifications-methods October 27, 2025 14:10
@nickolas-dimitrakas nickolas-dimitrakas changed the title Refactor/replace static methods in mp notification controller and mp state machine refactor: replace static methods in mp notification controller and mp state machine Oct 27, 2025
@nickolas-dimitrakas nickolas-dimitrakas force-pushed the refactor/replace-static-methods-in-MPNotificationController-and-MPStateMachine branch 6 times, most recently from 25707f8 to 0ca99c9 Compare October 27, 2025 20:38
@nickolas-dimitrakas nickolas-dimitrakas force-pushed the refactor/replace-static-methods-in-MPNotificationController-and-MPStateMachine branch from 0ca99c9 to 16a454d Compare October 27, 2025 20:54
@nickolas-dimitrakas nickolas-dimitrakas merged commit a028908 into test/add-test-coverage-for-application-notifications-methods Oct 28, 2025
10 of 11 checks passed
@nickolas-dimitrakas nickolas-dimitrakas deleted the refactor/replace-static-methods-in-MPNotificationController-and-MPStateMachine branch October 28, 2025 14:07
nickolas-dimitrakas added a commit that referenced this pull request Oct 30, 2025
* refactor: remove static methods in MPNotificationController and deprecate MPStateMachine (#434)

* Created app environment provider

* replaced usage of static methods in mP.m

* Create protocol for MPNotificationController

* switched from static methods

* replaced usage of notif controller static methods

* removed initialization from methods to class init

* fixed compilation issue

* Update mParticle_iOS_SDKTests-Bridging-Header.h

* make properties nonnull

* Revert removal of static method and mark deprecation instead

* put back deprecated static methods in implementation

* cleaned up duplicated code

* marked isAppExtension static method for deprecation

* Update build-and-lint.yml

* Revert to commit 0277379

* mark for deprecated method

BREAKING CHANGE: Static methods in MPNotificationController have been fully removed. 
Use the new instance-based MPNotificationControllerProtocol implementation instead.

DEPRECATED: Static methods in MPStateMachine are deprecated and will be removed in a future release. 
Migrate to the new instance-based approach.

* Create mocks

* Update AppEnvironmentProviderMock.swift

* covered pushNotificationToken

* covered setPushNotificationToken

* Create protocol for MPAppNotificationHandler

* Create MPAppNotificationHandlerMock

* replace singleton usage of appNotificationHandler

* covered didReceiveRemoteNotification

* covered didFailToRegisterForRemoteNotificationsWithError

* covered didRegisterForRemoteNotificationsWithDeviceToken

* covered handleActionWithIdentifierForRemoteNotification

* covered handleActionWithIdentifierForRemoteNotificationWithResponseInfo

* covered openURL methods

* covered continueUserActivity

* Update MPAppNotificationHandlerMock.swift
nickolas-dimitrakas added a commit that referenced this pull request Oct 30, 2025
…cate MPStateMachine (#434)

* Created app environment provider

* replaced usage of static methods in mP.m

* Create protocol for MPNotificationController

* switched from static methods

* replaced usage of notif controller static methods

* removed initialization from methods to class init

* fixed compilation issue

* Update mParticle_iOS_SDKTests-Bridging-Header.h

* make properties nonnull

* Revert removal of static method and mark deprecation instead

* put back deprecated static methods in implementation

* cleaned up duplicated code

* marked isAppExtension static method for deprecation

* Update build-and-lint.yml

* Revert to commit 0277379

* mark for deprecated method

BREAKING CHANGE: Static methods in MPNotificationController have been fully removed.
Use the new instance-based MPNotificationControllerProtocol implementation instead.

DEPRECATED: Static methods in MPStateMachine are deprecated and will be removed in a future release.
Migrate to the new instance-based approach.
mparticle-automation added a commit that referenced this pull request Jan 14, 2026
### Bug Fixes

* Crash on launch when upgrading due to NSInvalidUnarchiveOperationException ([#469](#469)) ([5241667](5241667))
* Flakey test testLoggingCommerceEventToUpload ([#475](#475)) ([6cb3475](6cb3475))
* Handle Parenthesis in Release Notes ([#487](#487)) ([a9ab226](a9ab226))
* Rokt User Attribute Mapping Fix ([#478](#478)) ([9f56a05](9f56a05))
* Simulator not found failing CI ([#472](#472)) ([33df791](33df791))
* Use awk for changelog ([#488](#488)) ([16fa905](16fa905))

### Features

* Add IntegrationTests project with Tuist and WireMock setup ([#451](#451)) ([a1e51fc](a1e51fc))
* Add trunk rule to detect mParticle API keys ([#481](#481)) ([d78a8ec](d78a8ec))
* Implement Manual Scene Delegate Support ([#462](#462)) ([71fe8b7](71fe8b7))
* Implement Manual SceneDelegate Support ([#453](#453)) ([e5cbe84](e5cbe84))
* SDKE-528 Implement Script To Preprocess Request Recordings ([#452](#452)) ([69a8ed3](69a8ed3))
* SDKE-529 Implement Verification Script ([#454](#454)) ([d5e25e0](d5e25e0))

### Reverts

* Revert "feat: Implement Manual SceneDelegate Support ([#453](#453))" ([#455](#455)) ([d13601e](d13601e))

### Tests

* add test coverage for application notifications methods ([#436](#436)) ([d2243aa](d2243aa)), closes [#434](#434)

### BREAKING CHANGES

* Static methods in MPNotificationController have been fully removed.
Use the new instance-based MPNotificationControllerProtocol implementation instead.

DEPRECATED: Static methods in MPStateMachine are deprecated and will be removed in a future release.
Migrate to the new instance-based approach.

* Create mocks

* Update AppEnvironmentProviderMock.swift

* covered pushNotificationToken

* covered setPushNotificationToken

* Create protocol for MPAppNotificationHandler

* Create MPAppNotificationHandlerMock

* replace singleton usage of appNotificationHandler

* covered didReceiveRemoteNotification

* covered didFailToRegisterForRemoteNotificationsWithError

* covered didRegisterForRemoteNotificationsWithDeviceToken

* covered handleActionWithIdentifierForRemoteNotification

* covered handleActionWithIdentifierForRemoteNotificationWithResponseInfo

* covered openURL methods

* covered continueUserActivity

* Update MPAppNotificationHandlerMock.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants