Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#import <Foundation/Foundation.h>
@class MSNotificationHub;
@class MSInstallation;
@protocol MSInstallationEnrichmentDelegate <NSObject>
@optional
- (void)notificationHub:(MSNotificationHub *)notificationHub willEnrichInstallation:(MSInstallation *)installation;
@end
#import <Foundation/Foundation.h>
@class MSNotificationHub;
@class MSInstallation;
@protocol MSInstallationManagementDelegate <NSObject>
@optional
- (void)notificationHub:(MSNotificationHub *)notificationHub willUpsertInstallation:(MSInstallation *)installation;
- (void)notificationHub:(MSNotificationHub *)notificationHub willDeleteInstallation:(NSString *)installationId;
@end
#import <Foundation/Foundation.h>
#import "MSInstallationEnrichmentDelegate.h"
#import "MSInstallationManagementDelegate.h"
@interface MSNotificationHub : NSObject
// Other details not in scope
@property(nonatomic) id<MSInstallationEnrichmentDelegate> enrichmentDelegate;
@property(nonatomic) id<MSInstallationManagementDelegate> managementDelegate;
+ (void)setEnrichmentDelegate:(nullable id<MSInstallationEnrichmentDelegate>)enrichmentDelegate;
+ (void)setManagementDelegate:(nullable id<MSInstallationManagementDelegate>)managementDelegate;
@end
@brannon
Copy link

brannon commented May 6, 2020

I'm just not a fan of the term "enrich" in an SDK. On the Android side we went with "visitor", which also isn't great.. but at least it's more commonly used.

@brannon
Copy link

brannon commented May 6, 2020

I'm also not sure the "willDo" pattern is appropriate here. "will" typically means: we're about to do something, here's a chance to hook into the lifecycle. In this case there's no lifecycle, the delegate method is expected to do the work.

That also applies to delegate methods right? If the delegate is optional, and isn't set, then what should be the default behavior? I would think there wouldn't be a default behavior in that case.

For our case, we need the default behavior to be sending the Installation to the NH API.

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