Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Last active May 6, 2020 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/ce529abe5cd5fa2159004e0cf98d2483 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/ce529abe5cd5fa2159004e0cf98d2483 to your computer and use it in GitHub Desktop.
#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