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

Support for authorization added #54

Merged
merged 3 commits into from
Aug 4, 2021
Merged

Conversation

philips77
Copy link
Member

This PR fixes #46.

However, it implement this feature some breaking changes had to be made:

  • CBMCentralManager was refactored from a protocol to a class with internal init. This was required so the type methods (CBMCentralManager.authorization and CBMCentralManager.supports(:)) could be called on the main manager without the need of specifying mock or native manager.

    Note: The behavior of those methods is not trivial. If simulated values were set in CBMCentralManagerMock.simulateAuthorization(:) and CBMCentralManagerMock.simulateFeatureSupport, the above-mentioned methods will return simulated values. Otherwise, the native implementation will be returned. To always get native implementation use CBMCentralManagerNative.authorization and CBMCentralManagerNative.supports(:). On the other hand, to always get mock values, use CBMCentralManagerMock.authorization and CBMCentralManagerMock.supports(:).

  • simulateStateRestoration and simulateFeaturesSupport were moved from CBMCentralManagerFactory to CBMCentralManagerMock. This groups all the simulate... methods together. That was not required, but I think the API is now more clear.

  • A new static method simulateAuthorization(:) was added to CBMCentralManagerMock. It's available from iOS 13.0. By default, the mock manager has authorization .allowedAlways. This method allows to set different values. Other values will cause all the CBMCentralManager to transition to CBMManagerState.unauthorized state.

@philips77 philips77 added the enhancement New feature or request label Aug 4, 2021
@philips77 philips77 merged commit 5dc60c7 into develop Aug 4, 2021
@philips77 philips77 deleted the feature/authorizarion branch August 4, 2021 12:55
@evnik
Copy link

evnik commented Aug 5, 2021

@philips77 Could you guys please keep CBMCentralManager as a protocol or provide another protocol which will be accepted by CBMCentralManagerDelegate. We would like to keep our own implementation of this protocol, where we can mock whatever we want to return through it.

@philips77
Copy link
Member Author

Git it. I'll add the protocol, like you suggested. Thank you for the feedback.

@philips77
Copy link
Member Author

And for this purpose I'd like to ask for proposals for the name of this protocol.
CBMCentralManagerable? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants