@@ -27,14 +27,32 @@ @interface BranchActivityItemProvider ()
2727
2828@implementation BranchActivityItemProvider
2929
30- - (id )initWithParams : (NSDictionary *)params andTags : (NSArray *)tags andFeature : (NSString *)feature andStage : (NSString *)stage andAlias : (NSString *)alias {
30+ - (id )initWithParams : (NSDictionary *)params
31+ andTags : (NSArray *)tags
32+ andFeature : (NSString *)feature
33+ andStage : (NSString *)stage
34+ andAlias : (NSString *)alias {
3135 return [self initWithParams: params tags: tags feature: feature stage: stage campaign: nil alias: alias delegate: nil ];
3236}
3337
34- - (id )initWithParams : (NSDictionary *)params tags : (NSArray *)tags feature : (NSString *)feature stage : (NSString *)stage campaign : (NSString *)campaign alias : (NSString *)alias delegate : (id <BranchActivityItemProviderDelegate>)delegate {
35- NSString *url = [[Branch getInstance ] getLongURLWithParams: params andChannel: nil andTags: tags andFeature: feature andStage: stage andAlias: alias];
36-
37- if ([UIDevice currentDevice ].systemVersion .doubleValue < 11.0 ) {
38+ - (id )initWithParams : (NSDictionary *)params
39+ tags : (NSArray *)tags
40+ feature : (NSString *)feature
41+ stage : (NSString *)stage
42+ campaign : (NSString *)campaign
43+ alias : (NSString *)alias
44+ delegate : (id <BranchActivityItemProviderDelegate>)delegate {
45+
46+ NSString *url =
47+ [[Branch getInstance ]
48+ getLongURLWithParams: params
49+ andChannel: nil
50+ andTags: tags
51+ andFeature: feature
52+ andStage: stage
53+ andAlias: alias];
54+
55+ if (self.returnURL ) {
3856 if ((self = [super initWithPlaceholderItem: [NSURL URLWithString: url]])) {
3957 _params = params;
4058 _tags = tags;
@@ -60,9 +78,19 @@ - (id)initWithParams:(NSDictionary *)params tags:(NSArray *)tags feature:(NSStri
6078 return self;
6179}
6280
81+ - (BOOL ) returnURL {
82+ BOOL returnURL = YES ;
83+ if ([UIDevice currentDevice ].systemVersion .doubleValue >= 11.0 &&
84+ [self .activityType isEqualToString: UIActivityTypeCopyToPasteboard]) {
85+ returnURL = NO ;
86+ }
87+ return returnURL;
88+ }
89+
6390- (id )item {
6491 NSString *channel = [BranchActivityItemProvider humanReadableChannelWithActivityType: self .activityType];
65-
92+
93+
6694 // Allow for overrides specific to channel
6795 NSDictionary *params = [self paramsForChannel: channel];
6896 NSArray *tags = [self tagsForChannel: channel];
@@ -91,7 +119,7 @@ - (id)item {
91119 andAlias: alias
92120 ignoreUAString: self .userAgentString
93121 forceLinkCreation: YES ]];
94- return ([UIDevice currentDevice ]. systemVersion . doubleValue < 11.0 ) ? URL : URL.absoluteString ;
122+ return (self. returnURL ) ? URL : URL.absoluteString ;
95123 }
96124 }
97125
@@ -134,7 +162,7 @@ - (id)item {
134162 andAlias: alias
135163 ignoreUAString: nil
136164 forceLinkCreation: YES ]];
137- return ([UIDevice currentDevice ]. systemVersion . doubleValue < 11.0 ) ? URL : URL.absoluteString ;
165+ return (self. returnURL ) ? URL : URL.absoluteString ;
138166}
139167
140168#pragma mark - Internals
@@ -175,28 +203,39 @@ + (NSString *)humanReadableChannelWithActivityType:(NSString *)activityString {
175203}
176204
177205- (NSDictionary *)paramsForChannel : (NSString *)channel {
178- return ([self .delegate respondsToSelector: @selector (activityItemParamsForChannel: )]) ? [self .delegate activityItemParamsForChannel: channel] : self.params ;
206+ return ([self .delegate respondsToSelector: @selector (activityItemParamsForChannel: )])
207+ ? [self .delegate activityItemParamsForChannel: channel]
208+ : self.params ;
179209}
180210
181211- (NSArray *)tagsForChannel : (NSString *)channel {
182- return ([self .delegate respondsToSelector: @selector (activityItemTagsForChannel: )]) ? [self .delegate activityItemTagsForChannel: channel] : self.tags ;
212+ return ([self .delegate respondsToSelector: @selector (activityItemTagsForChannel: )])
213+ ? [self .delegate activityItemTagsForChannel: channel]
214+ : self.tags ;
183215}
184216
185217- (NSString *)featureForChannel : (NSString *)channel {
186- return ([self .delegate respondsToSelector: @selector (activityItemFeatureForChannel: )]) ? [self .delegate activityItemFeatureForChannel: channel] : self.feature ;
218+ return ([self .delegate respondsToSelector: @selector (activityItemFeatureForChannel: )])
219+ ? [self .delegate activityItemFeatureForChannel: channel]
220+ : self.feature ;
187221}
188222
189223- (NSString *)stageForChannel : (NSString *)channel {
190- return ([self .delegate respondsToSelector: @selector (activityItemStageForChannel: )]) ? [self .delegate activityItemStageForChannel: channel] : self.stage ;
224+ return ([self .delegate respondsToSelector: @selector (activityItemStageForChannel: )])
225+ ? [self .delegate activityItemStageForChannel: channel]
226+ : self.stage ;
191227}
192228
193229- (NSString *)campaignForChannel : (NSString *)channel {
194- return ([self .delegate respondsToSelector: @selector (activityItemCampaignForChannel: )]) ? [self .delegate activityItemCampaignForChannel: channel] : self.campaign ;
230+ return ([self .delegate respondsToSelector: @selector (activityItemCampaignForChannel: )])
231+ ? [self .delegate activityItemCampaignForChannel: channel]
232+ : self.campaign ;
195233}
196234
197-
198235- (NSString *)aliasForChannel : (NSString *)channel {
199- return ([self .delegate respondsToSelector: @selector (activityItemAliasForChannel: )]) ? [self .delegate activityItemAliasForChannel: channel] : self.alias ;
236+ return ([self .delegate respondsToSelector: @selector (activityItemAliasForChannel: )])
237+ ? [self .delegate activityItemAliasForChannel: channel]
238+ : self.alias ;
200239}
201240
202241@end
0 commit comments