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(IoT): Adding completion callbacks for registerWithShadow and unregisterFromShadow methods #5192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ruisebas
Copy link
Member

@ruisebas ruisebas commented Feb 9, 2024

Issue #, if available:

Description of changes:

This PR adds the following methods to AWSIoTDataManager:

  • registerWithShadow:options:eventCallback:completionCallback:
  • unregisterFromShadow:completionCallback:

They are basically just overloading the existing ones with the addition of the completionCallback argument, which is invoked when the subscription to all topics is done.

The reasoning behind this is to provide a way for consumers to know when the subscription is actually done and they can get the shadow (see the referenced issue for more information).

Check points:

  • Added new tests to cover change, if needed
  • All unit tests pass
  • All integration tests pass
  • Updated CHANGELOG.md
  • Documentation update for the change if required
  • PR title conforms to conventional commit style

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

- (BOOL) registerWithShadow:(NSString *)name
options:(NSDictionary *)options
eventCallback:(void(^)(NSString *name, AWSIoTShadowOperationType operation, AWSIoTShadowOperationStatusType status, NSString *clientToken, NSData *payload))callback
completionHandler:(nullable void(^)(void))completionHandler {
Copy link
Member Author

Choose a reason for hiding this comment

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

Having the nullable annotation in the interface method resulted in weird stuff when the method was translated to Swift and autocompletion was attempted.

While not an error itself, I rather just do this to avoid confusing consumers, i.e. having the completionCallback declared as nonnull and having an implementation-only method that can take nil.

The same applies for the unregisterFromShadow method

@ruisebas ruisebas marked this pull request as ready for review February 9, 2024 20:53
@ruisebas ruisebas requested review from awsmobilesdk and a team as code owners February 9, 2024 20:53
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.

None yet

1 participant