Skip to content

Commit c651c01

Browse files
authored
Merge pull request #146 from BranchMetrics/INTENG-16921
[INTENG-16921] Add new method for adding multiple content items to events
2 parents c4a483f + 66a9ed5 commit c651c01

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Branch-Xamarin-SDK/Model/BranchEvent.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ public void AddContentItem(BranchUniversalObject contentItem)
100100
contentItems.Add(contentItem.ToJsonString());
101101
}
102102

103+
// Use this method to add multiple BranchUniversalObjects associated with this event
104+
public void AddContentItems(List<BranchUniversalObject> contentItemsToAdd)
105+
{
106+
foreach (var item in contentItemsToAdd) {
107+
contentItems.Add(item.ToJsonString());
108+
}
109+
}
110+
103111
public Dictionary<string, object> ToDictionary()
104112
{
105113
var dataToSend = new Dictionary<string, object>(data);

Branch-Xamarin-Testbed/UI/TestPage.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
using System;
44
using System.Collections.Generic;
55
using System.ComponentModel;
6-
76
using Xamarin.Forms;
87

98
namespace BranchXamarinTestbed
109
{
11-
public class TestPage : ContentPage ,
10+
public class TestPage : ContentPage,
1211
IBranchUrlInterface,
1312
IBranchSessionInterface,
1413
IBranchIdentityInterface
@@ -370,6 +369,13 @@ void GetUrlClicked(object sender, EventArgs e) {
370369

371370
Branch.GetInstance().GetShortURL(this, universalObject, linkProperties);
372371

372+
BranchUniversalObject buoTwo = new BranchUniversalObject();
373+
buoTwo.canonicalIdentifier = "id2";
374+
buoTwo.metadata.AddCustomMetadata("testCustom", "testData");
375+
376+
List<BranchUniversalObject> buos = new List<BranchUniversalObject>();
377+
buos.Add(universalObject);
378+
buos.Add(buoTwo);
373379

374380
BranchEvent branchEvent = new BranchEvent("MY_CUSTOM_EVENT");
375381
branchEvent.SetAffiliation("my_affilation");
@@ -381,11 +387,11 @@ void GetUrlClicked(object sender, EventArgs e) {
381387
branchEvent.SetDescription("my_description");
382388
branchEvent.SetSearchQuery("my_search_query");
383389
branchEvent.AddCustomData("custom_data_key01", "custom_data_value01");
384-
branchEvent.AddContentItem(universalObject);
390+
branchEvent.AddContentItems(buos);
385391

386392
Branch.GetInstance().SendEvent(branchEvent);
387393
}
388-
394+
389395
void SendEmailClicked(object sender, EventArgs e) {
390396
if (UriString != null) {
391397
// DependencyService.Get<IEmailUrl> ().EmailUrl (UriString);

0 commit comments

Comments
 (0)