Пример #1
0
        public override void RegisterView(BranchUniversalObject universalObject)
        {
            IO.Branch.Indexing.BranchUniversalObject resBuo =
                IO.Branch.Indexing.BranchUniversalObject.CreateInstance(BranchAndroidUtils.ToJSONObject(universalObject.ToDictionary()));

            resBuo.RegisterView();
        }
Пример #2
0
        public override void ShareLink(IBranchLinkShareInterface callback,
                                       BranchUniversalObject universalObject,
                                       BranchLinkProperties linkProperties,
                                       string message)
        {
            BranchLinkShareListener obj = new BranchLinkShareListener(callback);

            callbacksList.Add(obj as Object);

            IO.Branch.Indexing.BranchUniversalObject resBuo = BranchAndroidUtils.ToNativeBUO(universalObject);
            IO.Branch.Referral.Util.LinkProperties   resBlp = BranchAndroidUtils.ToNativeBLP(linkProperties);

            IO.Branch.Referral.Util.ShareSheetStyle style =
                new IO.Branch.Referral.Util.ShareSheetStyle(appContext, "", message);

            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Facebook);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Twitter);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Message);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Email);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Flickr);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.GoogleDoc);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.WhatsApp);

            resBuo.ShowShareSheet(CurrActivity, resBlp, style, obj);
        }
Пример #3
0
        public static IO.Branch.Indexing.BranchUniversalObject ToNativeBUO(BranchUniversalObject buo)
        {
            IO.Branch.Indexing.BranchUniversalObject resBuo = new IO.Branch.Indexing.BranchUniversalObject();

            foreach (string keyword in buo.keywords)
            {
                resBuo.AddKeyWord(keyword);
            }

            foreach (string key in buo.metadata.Keys)
            {
                resBuo.AddContentMetadata(key, buo.metadata[key]);
            }

            resBuo.SetCanonicalIdentifier(buo.canonicalIdentifier);
            resBuo.SetCanonicalUrl(buo.canonicalUrl);
            resBuo.SetTitle(buo.title);
            resBuo.SetContentDescription(buo.contentDescription);
            resBuo.SetContentImageUrl(buo.imageUrl);
            resBuo.SetContentType(buo.type);

            if (buo.contentIndexMode == 0)
            {
                resBuo.SetContentIndexingMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Public);
            }
            else
            {
                resBuo.SetContentIndexingMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Private);
            }

            Java.Util.Date date = new Java.Util.Date(buo.expirationDate.HasValue ? (buo.expirationDate.Value.Ticks / 10000) : 0);
            resBuo.SetContentExpiration(date);

            return(resBuo);
        }
Пример #4
0
        public override void GetShortURL(IBranchUrlInterface callback,
                                         BranchUniversalObject universalObject,
                                         BranchLinkProperties linkProperties)
        {
            BranchUrlListener obj = new BranchUrlListener(callback);

            callbacksList.Add(obj as Object);

            IO.Branch.Indexing.BranchUniversalObject resBuo =
                IO.Branch.Indexing.BranchUniversalObject.CreateInstance(BranchAndroidUtils.ToJSONObject(universalObject.ToDictionary()));

            IO.Branch.Referral.Util.LinkProperties resBlp =
                new IO.Branch.Referral.Util.LinkProperties();

            foreach (string tag in linkProperties.tags)
            {
                resBlp.AddTag(tag);
            }

            foreach (string key in linkProperties.controlParams.Keys)
            {
                resBlp.AddControlParameter(key, linkProperties.controlParams[key]);
            }

            resBlp.SetAlias(linkProperties.alias);
            resBlp.SetChannel(linkProperties.channel);
            resBlp.SetDuration(linkProperties.matchDuration);
            resBlp.SetFeature(linkProperties.feature);
            resBlp.SetStage(linkProperties.stage);

            resBuo.GenerateShortUrl(appContext, resBlp, obj);
        }
Пример #5
0
        public override void GetShortURL(IBranchUrlInterface callback,
                                         BranchUniversalObject universalObject,
                                         BranchLinkProperties linkProperties)
        {
            BranchUrlListener obj = new BranchUrlListener(callback);

            callbacksList.Add(obj as Object);

            IO.Branch.Indexing.BranchUniversalObject resBuo = BranchAndroidUtils.ToNativeBUO(universalObject);
            IO.Branch.Referral.Util.LinkProperties   resBlp = BranchAndroidUtils.ToNativeBLP(linkProperties);

            resBuo.GenerateShortUrl(appContext, resBlp, obj);
        }
Пример #6
0
        public static IO.Branch.Indexing.BranchUniversalObject ToNativeBUO(BranchUniversalObject buo)
        {
            IO.Branch.Indexing.BranchUniversalObject resBuo = new IO.Branch.Indexing.BranchUniversalObject();

            resBuo.SetCanonicalIdentifier(buo.canonicalIdentifier);
            resBuo.SetCanonicalUrl(buo.canonicalUrl);
            resBuo.SetTitle(buo.title);
            resBuo.SetContentDescription(buo.contentDescription);
            resBuo.SetContentImageUrl(buo.imageUrl);

            if (buo.contentIndexMode == 0)
            {
                resBuo.SetContentIndexingMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Public);
            }
            else
            {
                resBuo.SetContentIndexingMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Private);
            }

            if (buo.localIndexMode == 0)
            {
                resBuo.SetLocalIndexMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Public);
            }
            else
            {
                resBuo.SetLocalIndexMode(IO.Branch.Indexing.BranchUniversalObject.CONTENT_INDEX_MODE.Private);
            }

            Java.Util.Date date = new Java.Util.Date(buo.expirationDate.HasValue ? (buo.expirationDate.Value.Ticks / 10000) : 0);
            resBuo.SetContentExpiration(date);

            foreach (string keyword in buo.keywords)
            {
                resBuo.AddKeyWord(keyword);
            }

            JSONObject dict = new JSONObject(buo.metadata.ToJsonString());

            if (dict != null)
            {
                IO.Branch.Referral.Util.ContentMetadata cmd =
                    IO.Branch.Referral.Util.ContentMetadata.CreateFromJson(new IO.Branch.Referral.BranchUtil.JsonReader(dict));

                if (cmd != null)
                {
                    resBuo.SetContentMetadata(cmd);
                }
            }

            return(resBuo);
        }
        public static Dictionary <string, object> ToDictionary(IO.Branch.Indexing.BranchUniversalObject data)
        {
            if (data == null)
            {
                return(new Dictionary <string, object> ());
            }

            var keywordsList = new List <object>();

            if (data.Keywords != null)
            {
                foreach (object obj in data.Keywords)
                {
                    keywordsList.Add(obj);
                }
            }

            var metadataDict = new Dictionary <string, object>();

            if (data.Metadata != null)
            {
                foreach (string key in data.Metadata.Keys)
                {
                    metadataDict.Add(key, data.Metadata[key]);
                }
            }

            var dict = new Dictionary <string, object>();

            dict.Add("$canonical_identifier", data.CanonicalIdentifier == null ? "" : data.CanonicalIdentifier);
            dict.Add("$canonical_url", data.CanonicalUrl == null ? "" : data.CanonicalUrl);
            dict.Add("$og_title", data.Title == null ? "" : data.Title);
            dict.Add("$og_description", data.Description == null ? "" : data.Description);
            dict.Add("$og_image_url", data.ImageUrl == null ? "" : data.ImageUrl);
            dict.Add("$publicly_indexable", data.IsPublicallyIndexable ? "0" : "1");
            dict.Add("$locally_indexable", data.IsLocallyIndexable ? "0" : "1");
            dict.Add("$exp_date", data.ExpirationTime.ToString());

            if (keywordsList != null)
            {
                dict.Add("$keywords", keywordsList);
            }

            if (data.ContentMetadata != null)
            {
                dict.Add("metadata", ToDictionary(data.ContentMetadata.ConvertToJson()));
            }

            return(dict);
        }
Пример #8
0
        public override void ShareLink(IBranchLinkShareInterface callback,
                                       BranchUniversalObject universalObject,
                                       BranchLinkProperties linkProperties,
                                       string message)
        {
            BranchLinkShareListener obj = new BranchLinkShareListener(callback);

            callbacksList.Add(obj as Object);

            IO.Branch.Indexing.BranchUniversalObject resBuo =
                IO.Branch.Indexing.BranchUniversalObject.CreateInstance(BranchAndroidUtils.ToJSONObject(universalObject.ToDictionary()));

            IO.Branch.Referral.Util.LinkProperties resBlp =
                new IO.Branch.Referral.Util.LinkProperties();

            foreach (string tag in linkProperties.tags)
            {
                resBlp.AddTag(tag);
            }

            foreach (string key in linkProperties.controlParams.Keys)
            {
                resBlp.AddControlParameter(key, linkProperties.controlParams[key]);
            }

            resBlp.SetAlias(linkProperties.alias);
            resBlp.SetChannel(linkProperties.channel);
            resBlp.SetDuration(linkProperties.matchDuration);
            resBlp.SetFeature(linkProperties.feature);
            resBlp.SetStage(linkProperties.stage);

            IO.Branch.Referral.Util.ShareSheetStyle style =
                new IO.Branch.Referral.Util.ShareSheetStyle(appContext, "", message);

            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Facebook);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Twitter);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Message);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Email);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.Flickr);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.GoogleDoc);
            style.AddPreferredSharingOption(IO.Branch.Referral.SharingHelper.SHARE_WITH.WhatsApp);

            resBuo.ShowShareSheet(CurrActivity, resBlp, style, obj);
        }
        public void OnInitFinished(IO.Branch.Indexing.BranchUniversalObject buo,
                                   IO.Branch.Referral.Util.LinkProperties blp,
                                   IO.Branch.Referral.BranchError error)
        {
            if (callback == null)
            {
                return;
            }

            if (error == null)
            {
                callback.InitSessionComplete(new BranchUniversalObject(BranchAndroidUtils.ToDictionary(buo)),
                                             new BranchLinkProperties(BranchAndroidUtils.ToDictionary(blp)));
            }
            else
            {
                BranchError err = new BranchError(error.Message, error.ErrorCode);
                callback.SessionRequestError(err);
            }
        }
Пример #10
0
 public override void ListOnSpotlight(BranchUniversalObject universalObject)
 {
     IO.Branch.Indexing.BranchUniversalObject resBuo = BranchAndroidUtils.ToNativeBUO(universalObject);
     resBuo.ListOnGoogleSearch(appContext);
 }
Пример #11
0
 public override void RegisterView(BranchUniversalObject universalObject)
 {
     IO.Branch.Indexing.BranchUniversalObject resBuo = BranchAndroidUtils.ToNativeBUO(universalObject);
     NativeBranch.RegisterView(resBuo, null);
 }