|
| 1 | +// |
| 2 | +// BranchShareLink.h |
| 3 | +// Branch-SDK |
| 4 | +// |
| 5 | +// Created by Edward Smith on 3/13/17. |
| 6 | +// Copyright © 2017 Branch Metrics. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <Foundation/Foundation.h> |
| 10 | +#import "BranchUniversalObject.h" |
| 11 | +@class BranchShareLink; |
| 12 | + |
| 13 | +@protocol BranchShareLinkDelegate <NSObject> |
| 14 | +@optional |
| 15 | + |
| 16 | +/** |
| 17 | +This delegate method is called during the course of user interaction while sharing a |
| 18 | +Branch link. The linkProperties, such as channel, or the share text parameters can be |
| 19 | +altered as appropriate for the particular user-chosen activityType. |
| 20 | +
|
| 21 | +This delegate method will be called multiple times during a share interaction and might be |
| 22 | +called on a background thread. |
| 23 | +
|
| 24 | +@param shareLink The calling BranchShareLink that is currently sharing. |
| 25 | +*/ |
| 26 | +- (void) branchShareLinkWillShare:(BranchShareLink*_Nonnull)shareLink; |
| 27 | + |
| 28 | +/** |
| 29 | +This delegate method is called when sharing has completed. |
| 30 | +
|
| 31 | +@param shareLink The Branch share action sheet that has just completed. |
| 32 | +@param completed This parameter is YES if sharing completed successfully and the user did not cancel. |
| 33 | +@param error This parameter contains any errors that occurred will attempting to share. |
| 34 | +*/ |
| 35 | +- (void) branchShareLink:(BranchShareLink*_Nonnull)shareLink |
| 36 | + didComplete:(BOOL)completed |
| 37 | + withError:(NSError*_Nullable)error; |
| 38 | +@end |
| 39 | + |
| 40 | +#pragma mark - BranchShareLink |
| 41 | + |
| 42 | +/** |
| 43 | +The `BranchShareLink` class facilitates sharing Branch links using a `UIActivityViewController` |
| 44 | +user experience. |
| 45 | +
|
| 46 | +The `BranchShareLink` is a new class that is similar to but has more functionality than the old |
| 47 | +`[BranchUniversalObject showShareSheetWithLinkProperties:...]` methods. |
| 48 | +
|
| 49 | +The `BranchShareLink` is initialized with the `BranchUniversalObject` and `BranchLinkProperties` |
| 50 | +objects that will be used to generate the Branch link. |
| 51 | +
|
| 52 | +After the `BranchShareLink` object is created, set any configuration properties on the activity |
| 53 | +sheet object, and then call `showFromViewController:anchor:` to show the activity sheet. |
| 54 | +
|
| 55 | +A delegate on the BranchShareLink can further configure the share experience. For instance the link |
| 56 | +parameters can be changed depending on the activity that the user selects. |
| 57 | +*/ |
| 58 | + |
| 59 | +@interface BranchShareLink : NSObject |
| 60 | + |
| 61 | +/** |
| 62 | +Creates a BranchShareLink object. |
| 63 | +
|
| 64 | +@oaram universalObject The Branch Universal Object the will be shared. |
| 65 | +@param linkProperties The link properties that the link will have. |
| 66 | +*/ |
| 67 | +- (instancetype _Nullable) initWithUniversalObject:(BranchUniversalObject*_Nonnull)universalObject |
| 68 | + linkProperties:(BranchLinkProperties*_Nonnull)linkProperties; |
| 69 | + |
| 70 | + |
| 71 | +///Returns an array of activity item providers, one for the Branch Universal Object, |
| 72 | +///one for the share text (if provided), and one for the shareObject (if provided). |
| 73 | +- (NSArray<UIActivityItemProvider*>*_Nonnull) activityItems; |
| 74 | + |
| 75 | +/** |
| 76 | +Presents a UIActivityViewController that shares the Branch link. |
| 77 | +
|
| 78 | +@oaram viewController The parent view controller from which to present the the activity sheet. |
| 79 | +@param anchor The anchor point for the activity sheet. Used for iPad form factors. |
| 80 | +*/ |
| 81 | +- (void) presentActivityViewControllerFromViewController:(UIViewController*_Nullable)viewController |
| 82 | + anchor:(UIBarButtonItem*_Nullable)anchor; |
| 83 | + |
| 84 | +///The title for the share sheet. |
| 85 | +@property (nonatomic, strong) NSString*_Nullable title; |
| 86 | + |
| 87 | +///Share text for the item. |
| 88 | +///This text can be changed later when the `branchShareSheetWillShare:` delegate method is called. |
| 89 | +@property (nonatomic, strong) NSString*_Nullable shareText; |
| 90 | + |
| 91 | +///An additional, user defined, non-typed, object to be shared. |
| 92 | +///This object can be changed later when the `branchShareSheetWillShare:` delegate method is called. |
| 93 | +@property (nonatomic, strong) id _Nullable shareObject; |
| 94 | + |
| 95 | +///The resulting Branch URL that was shared. |
| 96 | +@property (nonatomic, strong, readonly) NSURL*_Nullable shareURL; |
| 97 | + |
| 98 | +///The activity type that the user chose. |
| 99 | +@property (nonatomic, strong, readonly) NSString*_Nullable activityType; |
| 100 | + |
| 101 | +///Extra server parameters that should be included with the link data. |
| 102 | +@property (nonatomic, strong) NSMutableDictionary*_Nullable serverParameters; |
| 103 | + |
| 104 | +///The Branch Universal Object that will be shared. |
| 105 | +@property (nonatomic, strong, readonly) BranchUniversalObject*_Nonnull universalObject; |
| 106 | + |
| 107 | +///The link properties for the created URL. |
| 108 | +@property (nonatomic, strong, readonly) BranchLinkProperties*_Nonnull linkProperties; |
| 109 | + |
| 110 | +///The delegate. See 'BranchShareLinkDelegate' above for a description. |
| 111 | +@property (nonatomic, weak) id<BranchShareLinkDelegate>_Nullable delegate; |
| 112 | +@end |
0 commit comments