Guest User

Untitled

a guest
Mar 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import Branch
  2.  
  3. public protocol BranchActivityObjectDelegate: BranchActivityItemProviderDelegate {}
  4.  
  5. public class BranchActivityObject: BranchUniversalObject {
  6.  
  7. private weak var delegate: BranchActivityObjectDelegate?
  8. private var params: [AnyHashable : Any]!
  9. private var linkProperties: BranchLinkProperties!
  10.  
  11. public init(delegate: BranchActivityObjectDelegate? = nil) {
  12. super.init()
  13. self.delegate = delegate
  14. }
  15.  
  16. public init(title: String, delegate: BranchActivityObjectDelegate? = nil) {
  17. super.init(title: title)
  18. self.delegate = delegate
  19. }
  20.  
  21. public init(canonicalIdentifier: String, delegate: BranchActivityObjectDelegate? = nil) {
  22. super.init(canonicalIdentifier: canonicalIdentifier)
  23. self.delegate = delegate
  24. }
  25.  
  26. public override func getBranchActivityItem(with linkProperties: BranchLinkProperties) -> UIActivityItemProvider? {
  27. params = getParamsForServerRequest(withAddedLinkProperties: linkProperties)
  28. if linkProperties.matchDuration > 0 {
  29. params[BRANCH_REQUEST_KEY_URL_DURATION] = linkProperties.matchDuration
  30. }
  31. if let campaign = linkProperties.campaign, !campaign.isEmpty {
  32. params[BRANCH_REQUEST_KEY_URL_CAMPAIGN] = linkProperties.campaign
  33. }
  34. self.linkProperties = linkProperties
  35. return Branch.getActivityItem(withParams: params, feature: linkProperties.feature, stage: linkProperties.stage, tags: linkProperties.tags, alias: linkProperties.alias, delegate: self)
  36. }
  37.  
  38. }
  39.  
  40. extension BranchActivityObject: BranchActivityObjectDelegate {
  41. public func activityItemParams(forChannel channel: String) -> [AnyHashable : Any] {
  42. return delegate?.activityItemParams?(forChannel: channel) ?? params
  43. }
  44. public func activityItemTags(forChannel channel: String) -> [Any] {
  45. return delegate?.activityItemTags?(forChannel: channel) ?? linkProperties.tags
  46. }
  47. public func activityItemFeature(forChannel channel: String) -> String {
  48. return delegate?.activityItemFeature?(forChannel: channel) ?? linkProperties.feature
  49. }
  50. public func activityItemStage(forChannel channel: String) -> String {
  51. return delegate?.activityItemStage?(forChannel: channel) ?? linkProperties.stage
  52. }
  53. public func activityItemCampaign(forChannel channel: String) -> String {
  54. return delegate?.activityItemCampaign?(forChannel: channel) ?? linkProperties.campaign
  55. }
  56. public func activityItemAlias(forChannel channel: String) -> String {
  57. return delegate?.activityItemAlias?(forChannel: channel) ?? linkProperties.alias
  58. }
  59. }
Add Comment
Please, Sign In to add comment